• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 28114
198
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.
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic