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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet working only when connected to VPN" Watch "Servlet working only when connected to VPN" New topic

Servlet working only when connected to VPN

Vijayata Bawankar

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 {
String userName = req.getParameter("userName");
String userPassword = req.getParameter("userPassword");
System.out.println("Inside queryOnDemand();");

URL url = new URL(queryStr);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
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!");
CookieValue = CookieValue.substring(CookieValue.indexOf("JSESSIONID"), CookieValue.indexOf("; path"));

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

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,
[ 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
author & internet detective

Joined: May 26, 2003
Posts: 33111

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

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Servlet working only when connected to VPN
It's not a secret anymore!