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:
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
- 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.