• 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

servlet running in different JVM than other servlets

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic