tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: Apache returning different sizes for same request [was Re: Controlling caching / session collision]
Date Thu, 13 Jan 2005 23:28:17 GMT
<%! String myVar ="";%>
creates an instance myVar in the servlet. Only 1 instance of a given servlet 
is loaded at a time and many requests all execute the service() method 
concurrently.

<%String myVar="";%>
would create a variable in the scope of the _jspService() method. Which is 
thread safe.


<jsp:useBean> is thread safe. (Unless the variable is pulled from application 
or session scope)

-Tim

Brian McEntire wrote:

> Ouch.  ;)
> 
> That was it. We searched through all the JSPs and fixed that in several 
> places. The problems are greatly reduced now. Thank you very much!
> 
> Is there any analog to this in Servlets? Is there a clearly incorrect 
> way variables could be scoped in the a Servlet that could lead to the 
> same thing?
> 
> The developer, within the JSPs, has a couple lines like:
> <jsp:useBean id="statehsaBean" class="postgres.PostgreSQLBean" 
> scope="page" />
> 
> And since we are still experiencing the problem (though much less), I 
> wonder if the Servlets now have some similar global variable problem.
> 
> Thanks again!
> 
>>
>> On Mon, 10 Jan 2005, Tim Funk wrote:
>>
>>> The code below is a disaster. It creates a variable called result at 
>>> the servlet instance level. This means that 2 concurrent requests to 
>>> that JSP page will cause the page to fail. I didn't read the reast of 
>>> the code - because that line is so evil - that ... well I'm speechless.
>>>
>>> Change it to:
>>> <%
>>>        ResultSet result;
>>> %>
>>>
>>>
>>> -Tim
>>>
>>>
>>> Brian McEntire wrote:
>>>
>>>> Looking at one of the problematic JSP pages, I see (snippets):
>>>>
>>>> <%!
>>>>         ResultSet result;
>>>> %>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
> 
> 

---------------------------------------------------------------------
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