This looks like a trick question to me!!!!!!
But....
<%! {all variables in here have class scope} %>
<% {all variables in here are local} %>
Take a close look at the ! (bang).
<%!
int globalCounter = 0;
%>
This page has been visited: <%= ++globalCounter %> times.
<p>
<%!
int localCounter = 0;
%>
NOW! This counter increases its value: <%= ++localCounter %>
Rick
On Wed, 14 Feb 1996, you wrote:
> > Hello Sir,
> I am Ravindra using tomcat 3.2.1 server in standalone mode
> for learning jsp .
> but problem is every time when i request for jsp page server
> is creating .java file & compiled it into class file .
> But this should not happened ,java file& class file should
> generate first time after change in jsp file .
> so i am facing problems for follwing counter.jsp example.
> when same jsp i am running through javawebserver2.0 it
> is working fine because java & class file is created after
> change in jsp only.not like previous case.
>
> Bellow i am giving code so please help me to solve the
> problem
>
> ---------------------------------------------------------------------------
>----------------------------------
>
>
> <%@ page language="java" contentType="text/html" %>
> <html>
> <head>
> <title>A page with a counter</title>
> </head>
> <body bgcolor="white">
> <%!
> int globalCounter = 0;
> %>
>
> This page has been visited: <%= ++globalCounter %> times.
>
> <p>
> <%
> int localCounter = 0;
> %>
> This counter never increases its value: <%= ++localCounter %>
>
> </body>
> </html>
>
> ---------------------------------------------------------------------------
>----------------------------------------------
>
> Thank you very much
>
> Regards
>
> Ravindra
----------------------------------------
Content-Type: text/html; name="Attachment: 1"
Content-Transfer-Encoding: quoted-printable
Content-Description:
----------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]