tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CPC Livelink Admin" <cpclv...@fitzpatrick.cc>
Subject RE: Regarding support for tomcat server....................
Date Thu, 15 Feb 2001 14:20:15 GMT

I think his point was that neither one was showing any value other than 1,
because the JSP was always recompiled, and then reloaded. Thus the class
variable was being reset to 0 as the class was reladed.

-----Original Message-----
From: Rick Roberts [mailto:tomcat@ait-web.com]
Sent: Thursday, February 15, 2001 10:16 AM
To: tomcat-user@jakarta.apache.org
Subject: Re: Regarding support for tomcat server....................


I don't know what's going on with your compile question, but your code is
wrong.  It should look like this:

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

If you set a local variable to 0 everytime you run the code then it's always
going to be 0.  So it's never going to increment.  Give localCounter class
scope, just like you gave globalCounter class scope and it will increment.

Rick




On Thu, 15 Feb 2001, you wrote:

> > Have you tried to disable browser cache?
>
> Attilio
>   ----- Original Message -----
>   From: Ravindra
>   To: bookquestions@oreilly.com
>   Cc: tomcat-user@jakarta.apache.org
>   Sent: Thursday, February 15, 1996 10:17 AM
>   Subject: Regarding support for tomcat server....................
>
>
>   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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-user-help@jakarta.apache.org



Mime
View raw message