Hi, I understand that on saying response.sendRedirect(), a new request would be created (effectively, the previously existing request would be lost). But, will the existing session be still available thru request.getSession(false)? The problem I am facing is: 1. I have two servlets running in my system, one for each application. 2. I want the values stored in the session to be shared between the two servlets (like When servlet1 redirects a particular request to servlet2). 3. Apart from composing a url with all the details needed by servlet2, I need certain other data to be taken from the session. Is it possible?
Session attributes are only shared by servlets within the same web application (i.e. war). Beyond that, they are not shared. Further, you of course cannot forward to a servlet in another app--you must redirect.
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Joined: May 06, 2003
hi, thanks for the info. Following this, if I return back to servlet 1 from servlet 2, will the values that I had stored in the session (before redirecting to servlet2) still be intact? The scenrio is like this: 1. I store some values in the session , before redirecting to servlet2 from servlet1. 2. when servlet2 redirects back to servlet1, i want servlet1 to pick up the previously stored values and continue. As it might be obvious, I am a beginner in this and not sure of my approach. Rhea
The values in the session will remain until one of the following happens: 1. They are explicity removed using session.removeAttribute(). 2. The sessions expires due to client inactivity. A session basically represents a conversation between a client (i.e the browser) and the server. Providing the user doesn't leave his desk for a long lunch break or sit looking at the same page for too long then the session will be retained on the server. HTH [ June 04, 2003: Message edited by: Andy Bowes ]
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Sharing session attributes between two servlets