• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic