Application Server Solutions for Microsoft IIS and ASP.NET
       solutions   products   partners   company   support   downloads         store
ServletExec Self-Help: FAQ
Back to Search >  Back to Search Results

Faq ID 149
Product ServletExec
Category Session Tracking, Web Application
Question Is there a way to share session data across different web applications on the same host ?
Answer With SE 5.0 this will be possible.
One way would be to use the JdbcSessionManager in your webapps so that session data is stored in a database. You'd also need to set the cookie path of your web-app session cookies to be a single forward slash (/) so that the client/browser will return the cookie to all webapps on that server no matter what their context path is. Another way would be to use the Pluggable Session Management feature added in SE 5.0 to write your own SessionManager and have your web-apps use the custom SessionManager that you write.

Prior to SE 5.0, no.
The Servlet 2.3 Specification indicates that Web Applications are to have separate and distinct, sessions and session management.
Specifically, that document says:
SRV.7.3 Session Scope HttpSession objects must be scoped at the application (or servlet context) level. 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 callee servlet must be different from those visible to the calling servlet.

However there are a few options available for transmitting information from one web application to another when using a version of SE which precedes SE 5.0:
  1. You could create your own cookie using a cookie path of '/' and return it in the response. Then the cookie would be sent in all subsequent requests (even requests for other web apps). Code in other web apps could then examine the request for this cookie and obtain its value. NOTE: This would not be a session cookie. It would simply be a custom cookie having a name and String value that your code can look for and use in some custom manner.
    This option is probably the most portable.
  2. You could use hidden form fields in the HTML that you web app code emits.
  3. You could enable context sharing for a ServletExec Virtual Server. This would allow servlets running in one web app to access the contexts of other web applications by using:
    Once a web app has a reference to the context of another web app,
    could be used to get attributes that had been previously set (in that other web-app's application scope, not the session scope).

    Note: this solution is not the best since it requires that the code have knowledge of how other web apps are deployed (their context path) and also may not be portable to other app server brands (context-sharing between web apps is not mandated by the Servlet 2.3 spec).

company media information terms of use privacy policy contact us