tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hume, John - NA US HQ Delray" <JH...@mytravelco.com>
Subject RE: Thread Safe JSP/Servlets
Date Mon, 29 Dec 2003 19:03:29 GMT
Instance variables in a JSP will be shared among requests, so you could have
an issue.  

Note however, that you have to go out of your way to declare instance
variables in a JSP (by putting them in a <%! //declaration block %> rather
than a plain old <% //scriptlet block %>).  All non-declarative scriptlets
and all static page content go into the service method of the JSP, so
they're threadsafe.  

-john.

-----Original Message-----
From: Merrill Cornish [mailto:merrill.cornish@earthlink.net]
Sent: Monday, December 29, 2003 1:55 PM
To: tomcat-user@jakarta.apache.org
Subject: Thread Safe JSP/Servlets


I understand how to write thread-safe software in general, but I suddenly
realized that I don't understand what, if anything, Tomcat "shares" among
different sessions (i.e., different users accessing the same JSP
application) and would therefore be thread sensitive.

For example, in my servlets, I have only constant class fields--no instance
fields.  All user-specific information is stored in session attributes that
exist only between user login and logout.  However, it finally dawned on me
that my JSP pages are quietly being turned into servlets behind my back
(this is despite my occassionally referencing the generated *_jsp files
while debugging), and those servlets DO have instance fields.

My specific question is whether Tomcat keeps the instance fields for JSP
servlets separate by session.  My more general request is for a pointer to
"best practices" documentation on how to keep JSPs and servlets thread safe.

Merrill Cornish

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message