Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

server down/up???

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic