• 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

How to check whether urlconnection is active?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am calling a servlet residing in a domino server from a java program.I am passing a cookie value but servlet is not getting invoked.I would like to know how i can test whether the connection is active or not(can you suggest any programs that i can use for testing the same)
I am providing here few lines of code which i am using to get urlconnection and set cookie.
HttpURLConnection urlconnection = null;
URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");
urlconnection= (HttpURLConnection)serverURL.openConnection();
urlconnection.setRequestProperty("cookie",cookie);
urlconnection.setRequestMethod("GET");
urlconnection.setFollowRedirects(true);
urlconnection.setDoOutput(true);
urlconnection.setDoInput(true);
Please go through and give suggestion/sample programs
Thanks and Regards
Subha
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is fine to some extent. I dont really understand what you really mean by 'connection is active or not'. If the openConnection method is successfull (without exception), it definitely means that the connection to the server is established. If the servlet does not get invoked, it indicates invalid usage of HTTP Protocol. If you use setdooutput(true) and setdoinput(true), you need to get the outputstream of the httpurlconnection and write whatever you want to write to it. Then u need to get the inputstream.
Also when you use setdooutput(true), setrequestmethod("GET") does not make sense because setdooutput(true) implicitly means you want POST method.

Originally posted by subha neithilath:
Hi,
I am calling a servlet residing in a domino server from a java program.I am passing a cookie value but servlet is not getting invoked.I would like to know how i can test whether the connection is active or not(can you suggest any programs that i can use for testing the same)
I am providing here few lines of code which i am using to get urlconnection and set cookie.
HttpURLConnection urlconnection = null;
URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");
urlconnection= (HttpURLConnection)serverURL.openConnection();
urlconnection.setRequestProperty("cookie",cookie);
urlconnection.setRequestMethod("GET");
urlconnection.setFollowRedirects(true);
urlconnection.setDoOutput(true);
urlconnection.setDoInput(true);
Please go through and give suggestion/sample programs
Thanks and Regards
Subha


[ November 11, 2002: Message edited by: Mohamed Yousuff ]
[ November 11, 2002: Message edited by: Mohamed Yousuff ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic