• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sharing Session across ServletContext

 
srinivasan ganesan
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Chen
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic