• 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 across ServletContext

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a situation where I want to share the session between 2 or more webapps. I would appreciate any help on this.
Thanks,
Srini
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you have found out, the whole purpose of Sun's servlet API is to keep web apps totally separate so you will have to go outside the servlet API to do this. There are plenty of options, for instance a separate database, RMI, etc.
Bill
 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,
Is there a reason why you shouldn't be able to do that? I couldnt come up with one. BTW all my applications reside in the same server. I appreciate your help on this.
Thanks,
Srini
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi srinivasan,
i tried to explore possibilities to do that in the SCWCD forum. have a look at that.
regards
maulin.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose to create one class and use singleton pattern to create only one instance in one init() of servlets, we can use this instance to share data between multi web apps.
Am I missing something?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating a class shared by both applications only works if both use the same ClassLoader - I don't think you can rely on it.
As I said, Sun's design requires "Web Applications" to be completely separate and independent. The reason being they want to encourage the sale of web applications and interactions between web applications would cause endless debugging problems.
The solution is to run an entirely separate application that any web application servlet can talk to and share data. This is easily done - you have several options. Chapter 9 in my servlets & JSP book works out an example using a Chat server as an example.
Bill
reply
    Bookmark Topic Watch Topic
  • New Topic