Restoring Http Session

Discussions

Web tier: servlets, JSP, Web frameworks: Restoring Http Session

  1. Restoring Http Session (5 messages)

    I've a scneraio where two web applications are logically connected. The user in the first application does a bunch of things, sticks a few objects with the http session and is then taken to the second web application. The user uses the second application for a new things and is taken back to the first application after a while. Would the user http session of the first application stays OR disappears since the user left the application temporarily?

    Besides this, are there other approaches of "restoring" user http sessions while switching applications?

    I could have tried this, but thought anyone might have run into this before and may help.

    Thanks.

    Threaded Messages (5)

  2. Restoring Http Session[ Go to top ]

    What you suggest is quite legitimate, and is known as the "Model 2" approach. In this model a servlet delegates ("dispatches") a request to another resource. Typically this is done by a RequestDispatcher, which can dispatch a request (by inclusion or forwarding) to other resources such as servlets or JSP's or even just plain HTML pages.

    The targeted resource can then access any data that has been placed in the request, including the session & application objects. So the session won't "disappear" as such unless it times out...it basically follows the request.
  3. Restoring Http Session[ Go to top ]

    Thanks Ian for your response.
    But I have two distinct applications (two war files) and as the servlet spec suggests, two web apps can NOT share the http sessions. This being the case, I am trying to find some way to keep the http session of one app alive even after user has left the application temporarily.
  4. Restoring Http Session[ Go to top ]

    Just set the timeout high enough ...

    If you need a custom clustered or cross-app session management implementation, drop a note to sales at tangosol dot com ... we have several implementations, and our free developer license includes the session management source code that works with our Coherence product.

    Peace,

    Cameron Purdy
    Tangosol, Inc.
    Coherence: Clustered JCache for Grid Computing!
  5. Restoring Http Session[ Go to top ]

    hi - i know this thread is a bit old but in searching for a solution to a problem, i came across this post which describes my issue exactly.

    does anyone out there have a complete answer on this one?

    i have two webapps and i need to go from one to another and then back. so i leave webapp1 to go to webapp2 via redirect and come back after i'm done in webapp2. when i come back to webapp1 and retrieve my session by calling HttpServletRequest.getSession(), doing so returns to me the session i started out with right? thus my session is intact and i can access my session information ,etc...?

    this of course assumes that i have not timed out yet with this scenario.

    thanks in advance for any insight.

    thx,
    -marco.
  6. Restoring Http Session[ Go to top ]

    Yes, your first webapp session will be alive within the timeout period. Basically how the session works is, when you create a session from your web app, the container creates a session object with an unique id(jsessionid) and creates a cookie with the jsessionid on it, while sending response(If cookie is disabled, it uses URLRewriting). While getting request from browser it reads the cookie and retrieves the session object from memory. So, the webapp1 doesn't care where you go and come as long as you access it within the timeout period.

    Hope this helps,
    Senthil.