jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Servlet working only when connected to VPN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet working only when connected to VPN" Watch "Servlet working only when connected to VPN" New topic
Author

Servlet working only when connected to VPN

Vijayata Bawankar
Greenhorn

Joined: Aug 20, 2008
Posts: 2
Hi all,

First of all sorry for the previous wrong post.

What i mean is,
I have written an servlet, wherein i have made a request to get the data from OnDemand server which is an secured server (https), it works fine if i am connected to VPN (i.e. with proxy) and does not give the repsonse if i am not connected to VPN.

I'm providing you the snippet of the servlet:

----------------------------------------------------------------------
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("application/xml");
String userName = req.getParameter("userName");
String userPassword = req.getParameter("userPassword");
System.out.println("Inside queryOnDemand();");

try
{
URL url = new URL(queryStr);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("GET");
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/xml");
urlConnection.setRequestProperty("UserName", userName);
urlConnection.setRequestProperty("Password", userPassword);

CookieValue = urlConnection.getHeaderField ("JSESSIONID").toString();

System.out.println("CookieValue ---> "+CookieValue);

if(CookieValue == "")
System.out.println("Login Failure!");
else
CookieValue = CookieValue.substring(CookieValue.indexOf("JSESSIONID"), CookieValue.indexOf("; path"));

System.out.println("My Seesion ID = " + CookieValue);
out.println(CookieValue);
} catch (Exception e) {
e.printStackTrace();
}
}
----------------------------------------------------------------------


So when i run the servlet and when connected to vpn through proxy, it does not give me the session ID.

So does anybody has any solution to it?

Thanks in advance,
Vijayata.
[ August 21, 2008: Message edited by: Vijayata Bawankar ]
Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
your body says the opposite of what you're topic says.

what exactly are you trying to do? when does it work and when does it not? do you have any logs?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Originally posted by Vijayata Bawankar:
doesnt work if i am not.

What does "doesn't work" mean. Please see why you should TellTheDetails.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet working only when connected to VPN
 
Similar Threads
URLConnection Doubts -- Urgent!!
Connecting to the webserver from simple java program with main method
HTTPS/ certificate problem
How to check whether urlconnection is active?
Posting to URLs with NON CGI Applications