You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Matt Jibson <do...@gmail.com> on 2006/08/14 18:14:31 UTC

JSP declarations persisting over page loads

Using Tomcat 5.5.17 and a HTML <body> of:

<%! boolean processed = false; %>
<br/><%=processed%>
<% processed = !processed; %>
<br/><%=processed%>

subsequent page loads will toggle the output. The first load is false,
true. Second true, false. Etc. This is reproducable in 5.0.28. Is this
expected behavior?

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JSP declarations persisting over page loads

Posted by Tim Lucia <ti...@yahoo.com>.
> -----Original Message-----
> From: Matt Jibson [mailto:dolmant@gmail.com]
> Sent: Monday, August 14, 2006 12:15 PM
> To: users@tomcat.apache.org
> Subject: JSP declarations persisting over page loads
> 
> Using Tomcat 5.5.17 and a HTML <body> of:
> 
> <%! boolean processed = false; %>
> <br/><%=processed%>
> <% processed = !processed; %>
> <br/><%=processed%>
> 
> subsequent page loads will toggle the output. The first load is false,
> true. Second true, false. Etc. This is reproducable in 5.0.28. Is this
> expected behavior?

Yes.  <%! ... %> creates page-wide definitions, which if you look at the
compiled .jsp (the .java file) you will notice it becomes a class variable.
If you use <% ... %> it is a local reference which gets initialized on every
request.

Google for jsp quick reference and you will find out more.

Tim



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org