• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic