hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject Re: Issue With HttpClient Session Handling
Date Wed, 08 Dec 2004 10:29:08 GMT
Hello  Manish,

could you be a little more specific about your usage of HttpClient?
Are you using it as a client to connect to a server where your
servlet is running? Or are you using it from a servlet to connect
to a backend server? Are you having problems with the client's
session kept on the server, or with a session of the server which
is kept on a backend server?

Your code fragment does not include the part that is most
important for session handling by HttpClient: which HttpState
object is used when the method is executed? That is where the
cookies are stored, and many servers use cookies to track the
session.

If you are trying to pass headers from a backend server through
your application to a client, you will also have problems with
cookie domains. Assuming three machines in different domains,
the server.at.the.backend will send a cookie for ".at.the.backend".
If the same cookie is returned by "server.in.the.middle", clients
will not accept a cookie for a domain other than ".in.the.middle".

cheers,
  Roland





"Manish Moorjani" <Manish_Moorjani@infosys.com> 
08.12.2004 11:11
Please respond to
"HttpClient Project"


To
<httpclient-dev@jakarta.apache.org>
cc

Subject
Issue With HttpClient Session Handling






Hi,
 
I am using HttpClient for automatic login into an application by calling
the Post Method.
 
PostMethod httpMethod = new PostMethod (strRemoteURL);
httpMethod.addParameter(new NameValuePair("fldUserId",strUserId));
httpMethod.addParameter(new NameValuePair("fldPassword",strPassword));
 
HttpConnection connConnection
=httpClient.getHttpConnectionManager().getConnection(httpClient.getHostC
onfiguration());
 
iStatusCode=httpMethod.execute(httpClient.getState(),connConnection);
 
After the execution is successful, I use the following code to set the
response headers
Header[] resHead=httpMethod.getResponseHeaders();
      for(int i=0;i<resHead.length;i++)
      {
            res.addHeader(resHead[i].getName(),resHead[i].getValue());
 
      }
 
Where res is HttpServletResponse .
 
Everything works fine for me, the cookies get set the browser.
But I am having the following issues
 
The response is like this
 
<html><head><script>window.open('test1','_top')</script></head></html>
 
In the test1 I have something like
req.getSession(true).getAttribute(attrb1)
Which is returning null !!!
 
It works fine If I access it directly, any inputs on this ????
 
 
 
 
 
Regards,
Manish Moorjani
 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message