maintaining the HTTPSession across multiple .war files

Discussions

General J2EE: maintaining the HTTPSession across multiple .war files

  1. Hi All,

    Problem Description:

    In our project currently, we have a single .war file which contains all the servlets for the whole application. The plan is to separate each tab (we have different Tabs for different screens for e.g. Trading screen, Settlement Screen etc. etc.) into different .war files, i.e. there will be multiple .wars like trading.war, settlement.war etc.

    Due to this, the problem arises of maintaining the HTTPSession across multiple .war files. Now, there are various attributes, e.g. user profile, which are stored in the session; and this information needs to be available to all the servlets in all the .wars.

    An Example (Simplified) Scenario:

    There are two servlets, ServletOne (included in war1.war) and ServletTwo (included in war2.war). ServletOne outputs a form with a button that redirects to ServletTwo.

    In ServletOne before redirecting, we set an attribute in the session:

    request.getSession(true).setAttribute("test", "test").

    In ServletTwo, we try to get the existing session and read the attribute:

    request.getSession(false).getAttribute("test"). At runtime, this throws NullPointerException because it is not able to obtain the session.

    Following approaches I tried and they did not work:

    - Deploy each .war separately
    - Package each .war into its own .ear and deploy the separate .ears
    - Package all .wars into a single .ear and deploy only this .ear

    Possible solutions:
    - HTTP Tunneling
    - Single Sign-On

    Has anybody of you worked on similar lines or anybody else who is associated with you? Some details I would like to know - are these the right solutions for our problem? How easy/difficult are they to implement? Or if you have a better solution for the problem above, it’s most welcome.

    Any suggestions you have would be most welcome.

    Shivam
  2. Hi Shivam,

    If you are in a clustered environment you may want to check out the Coherence*Web HTTP session management module included in the Coherence distribution. It which allows you to share session data across multiple web applications (detailed here) easily (i.e. no code change).

    Later,
    Rob Misek
    Tangosol, Inc.
    Coherence: It just works
  3. multiple war[ Go to top ]

    Hi ,
    I am also facig similar situation.But I am in the first stage.I am using tiles and for me each tile is comming from different war and I dont know how to access a jsp from different war .
  4. Re: multiple war[ Go to top ]

    Divakar: I don't believe you can since your crossing across containers.
  5. Hey Rob,

    I know its a little late (infact very late) a reply, but I guess its never too late to say Thank You.

    Shivam