Hi , I have a question. Form my servlet i am dispatching the request to another web application . Now the problem is if i set anything in the session object and then dispatch to another servlet in another web application i am not able to get values form the session that i had set previously.
I my second servlet i am using req.getSession(false) that means i am getting the same session object. Don't understand why the values from the session object is cleared. Am I doing something wrong.
Thanks in advance.
Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Yes. This is the right behavior indeed, because both applications are different. You can't share the session between two different apps. You can share that via DB or some file.
Joined: Aug 24, 2004
hi, Thanks for the reply. But i am not able to understand one thing. How this session object is associated with the web application. If my browser is sending the cookie having the session id and from my servlet i am forwarding the same request to a different web application then the server should return the same session object.
Indeed in my case the server is returning the same session object because in my second servlet i am using getSession(false) and the session id's are same. That means before the server is making the session object available in second servlet its clearing all the values. Is this what specs say. may be i will look into the spec.
Thanks for your reply.
Joined: Aug 24, 2004
I have heard that in websphere you can do it. There is this file sessionshare.xml. But as specs prohibits it its a non-J2EE way.
Yes, but you aren't getting the same sesssion object. You can't share session inforamtion accross webapps
SRV.7.3 Session Scope objects must be scoped at the application (or servlet context) level. HttpSession The underlying mechanism, such as the cookie used to establish the session, can be the same for different contexts, but the object referenced, including the attributes in that object, must never be shared between contexts by the container. To illustrate this requirement with an example: if a servlet uses the RequestDispatcher to call a servlet in another Web application, any sessions created for and visible to the servlet being called must be different from those visible to the calling servlet.
[ January 28, 2005: Message edited by: Ben Souther ]