• Post Reply Bookmark Topic Watch Topic
  • New Topic

server down/up???  RSS feed

 
sakthivel shan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I am trying to get authentication from my server, by using the below function...Here is a doubt...Once if my server is in "DOWN" state, i am getting the errors fired in my command prompt...how can i avoid this???.....i mean, i want to avoid the process of authentication, if the server is "DOWN"....how to find out whether a server is running in that url or not???

public String authenticateMe(String username, String password)
{
String setcookie="";
String cookie="";
try
{
URL theurl = new URL("http://192.168.10.55:8001/names.nsf?login&username=" + username + "&password=" + password);
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection hurl = (HttpURLConnection)theurl.openConnection();
hurl.connect();
setcookie = hurl.getHeaderField ("set-cookie");
if(setcookie!=null)
{
int index=setcookie.indexOf(";");
cookie=(setcookie.substring(0,index)).trim();
}
hurl.disconnect();
hurl=null;
}
catch(Exception exp)
{exp.printStackTrace();}
return cookie;
}

bye,
Sakthivel S.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!