Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet running in different JVM than other servlets  RSS feed

 
Josh Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In a web application I am working on, I have a servlet that can't seem to communicate with other servlets and JSP pages. There are 3 strange things happening.
1) If this servlet stores something in the Session, other servlets don't get that same session when they do a getSession().
2) If this servlet stores an attribute in the servlet context, other servlets can't see that attribute.
3) If this servlet instantiates a Singleton object (that all servlets are meant to share; ex: ConnectionPool), other servlets instantiate a whole new instance when they call getInstance() at a later time.
All the other servlets/JSPs share the ServletContext and Singleton objects. So this servlet looks like it runs in a separate JVM or is considered to be part of a separate web application. I just can't figure out why.
Tomcat is the servlet container we are using.
Any ideas?
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat has a number of ways of being configured and the number of JVMs can vary according to which you use. However, a "vanilla" tomcat I don't think is creating a distinct JVM for each servlet.
I suspect that a major problem you're having is not being aware of the details of the rules for session domains. A session is created (or retrieved) based on its URL name - check the docs for the exact details.
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you use:
HttpSession session=req.getSession(false);
?
--------------------
ruijin yang
SCJP2
 
Josh Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that the problem I was having was somehow caused by Tomcat.
I just moved the web app to iPlanet, and this problem does not occur anymore. Now sessions created by the troublesome servlet are seen by other servlets and jsp pages.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!