• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sharing Session between Two WAR Files

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to share some session objects between two war files on the same server. How can I get this done??? I have two war files service.war and retiree.war, You log into the Application from service.war, and set some session atributes such as the DBname, type, userid and a host of other attributes. All my JSPs and servlets in the retiree.war need this attributes. I am having trouble sharing the same session between both apps. Help please! By the way I am using a JBoss server.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


How can I get this done???


You can't. Session information is scoped to the current ServletContext, and there is one ServletContext per web app. ServletContext information is not designed to be shared.

One question which jumps out is if you have stuff in the session needed by both web apps, why do you have two web apps at all? Couldn't you combine them into one?

If you can't, you could just pass this info with the request.
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul Sturrock if it is not possible to share the same session across both webapps, is there a way I can make the retiree.war a module of service.war without having to put the content of retiree.war into the main application service.war?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No there is no parent child relationship between webapps.

Why did you make them two separate webapps?
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I am trying to accomplish is to have a web application that manages human resources in service.war and then have an optional package retiree.war that would only be distributed on request as a plus. I guess I will have to resort to just placing the contents of retiree.war in a separate folder inside service.war...

service.war
- /WEB-INF
- /retiree

Instead of
service.war & retiree.war, side by side.
 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of session objects you'd like to share? If it's just logged user credentials, then you can use single sign on approach. You can also pass data using HTML form hidden object, HTTP cookies and some other technique. If you know upfront servlet container where your apps will run on, then you can use some servlet container undocumented capabilities to share session objects.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic