tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Coetmeur, Alain" <alain.coetm...@caissedesdepots.fr>
Subject RE: Regarding support for tomcat server....................
Date Thu, 15 Feb 2001 17:49:41 GMT
moreover because Servlet may be pooled
in manyseparate instance,
each servlet may have it's own counter...

under low load it is not apparent,
but if you load the server with many concurent accesss
you will see that many different countes
will be incremented separately...

I've read somewhere that servlet should not have static
variable (it could be a solution)...
in fact in clustered servlet engine, there may be many
independent JavaVM that may not share even the class variables.


the solution is to use a singleton class through
a middleware.

one such way is to use a singleton Entity EJB !
sledge hammer to crack a nut! 8>>>

welcome to the strange country of potential multi-threading,
clustering and pooling !

if someone can explain me how to do it
rigourously but much more simply...

> -----Message d'origine-----
> De: Rick Roberts [mailto:tomcat@ait-web.com]
> Date: jeudi 15 février 2001 16:16
> À: tomcat-user@jakarta.apache.org
> Objet: 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