tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: BugRat Report #143 has been filed.
Date Wed, 20 Sep 2000 21:19:44 GMT
Philipp Winkler wrote:

> Some how the method to reproduce the bug didn't make it, so here it is:
>

It's really in the BugRat database; there is a bug in the way it displays
reports back out.

>
> Create a jsp with the following content:
> <html>
> <head>
>         <title>Untitled</title>
> </head>
> <%!String id;%>
> <%!int i;%>
> <%!int j;%>
> <% id = request.getParameter("id");%>
> <body>
> ID = <%=id%><BR>
>         <% for(i=0; i < 1000; i++){
>                 for(j=0; j < 1000000; j++);
>         }%>
> ID = <%=id%>
> </body>
> </html>
>
> Then open two browsers to this page. Set the id parameter uniquely for each.
> Start the second browser while the first browser is still retreving the
> page. The output should be something like:
> ID = run_1
> ID = run_2
>
> It does not seem to matter whether the second browsers is on a different or
> the same machine.
>

The page is behaving exactly as it is supposed to -- this is not a bug.

Variables you declare inside <%! ... %> become *instance* variables in the
generated servlet, which are shared across all requests because there is only
one instance of that servlet in memory.

If you want to declare variables that are local to the service() method of the
generated servlet (and therefore not shared between requests) you need to do
this instead:

    <% int i; %>
    <% int j; %>

(Note the lack of an exclamation point).

>
> -Phil

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



Mime
View raw message