Thanks.  'Twas never made clear in the specifications I saw.

> -----Original Message-----
> From: Tim Funk [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 04, 2003 4:45 PM
> To: Tomcat Users List
> Subject: Re: JSP Variable Declarations not thread-safe?
> 
> 
> This is not a tomcat problem. Variables should not be 
> declared in a <%! %> 
> block. If you do - they should be read only and set at init 
> time of the Jsp 
> (via jspInit())
> 
> If you need to declare variables, then declare them via <% .. 
> %>. These will 
> be locally scoped to the _jspService method.
> 
> -Tim
> 
> Kevin Klein wrote:
> > I am using Tomcat 4.1.18 with JDK 1.4.0 on Solaris.
> > 
> > I have a page with a JSP variable declaration of the following form:
> > 
> > <%!
> > Client client;
> > %>
> > 
> > Followed by some inline code snippets:
> > 
> > <%
> > client = someForm.getClient();
> > %>
> > 
> > Followed by various sections of JSP tags where I reference 
> attributes of
> > the object, e.g.:
> > 
> > <%= client.firstName %>
> > 
> > Problem is, when my application runs, the users are 
> occasionally seeing
> > values from other user sessions.  This made me immediately 
> suspect that
> > the generated JSP classes were not thread-sade.
> > 
> > I looked at the compiled code and saw that the declared 
> variables are
> > translated to member variables of the HttpJspBase subclass. 
>  If Tomcat
> > is not accurately tracking which JSP instances are in-use, 
> there is a
> > potential for these member variables to be overwritten by 
> other threads.
> > 
> > Is this a known bug or limitation in this version of 
> Tomcat?  Am I doing
> > something wrong?
> > 
> > In the meantime, I've moved the variable declarations 
> inside the code
> > snippet since that causes them to be declared in the method scope
> > instead of the class member scope.
> > 
> > Kevin Klein
> > 
> >  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to