In Tomcat 5.5 using several minor releases under both Windows and Linux
I am using the "session" variable in .jsps as provided in Tomcat's
default configuration, then setting and getting attributes. I can see
with multiple sessions that each instance gets a different session id
by displaying the session id via out.println(session). However, they
seem to share same attribute scope as if I am accessing an application
scoped context. Hence, if one session sets an Attribute (eg.
session.setAttribute("msg","test1")), and then subsequently another
session gets that Attribute (eg. session.getAttribute("msg")), it gets
the other session's value (eg "test1") not the what it previously set
that attribute to.
Tomcat generates java as follows for the "session" variable as follows:
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html");
pageContext = _jspxFactory.getPageContext(this, request,
response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
What's up? Thanks.
nobrentl@legacysol.net - 24 Jun 2006 15:20 GMT
My problem was statically declared variables within a messaging class
responsible for saving the system state between requests. Static
equates to one variable instance per VM.
Juha Laiho - 25 Jun 2006 13:10 GMT
nobrentl@legacysol.net said:
>My problem was statically declared variables within a messaging class
>responsible for saving the system state between requests. Static
>equates to one variable instance per VM.
Actually one variable per loaded class instance, and there are cases
where a single class is loaded multiple times in a single VM by different
classloaders (this is especially typical in servlet applications,
where the server creates a separate classloader for each deployed
application, but all the applications still run in a single VM).

Signature
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)