This article might interest you:
http://developer.java.sun.com/developer/onlineTraining/JSPIntro/exercises/Co
unter/
Note that if you want your counter data to persist in case the app server
dies you will have to store your counter in either a file or in a database.
How to read/write to a file/database? - I leave this as an exercise to the
reader :=)
-----Original Message-----
From: Kalman Hazins [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 17, 2001 5:51 AM
To: [EMAIL PROTECTED]
Subject: Re: JSP Counter
That was NOT the problem. It still does not work.
--- Kalman
----- Original Message -----
From: "Rishabh Agarwal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 17, 2001 12:20 AM
Subject: Re: JSP Counter
> When u declare a variable using declaration tag (<%!) , it is declared as
an
> instance variable and hence requires no explicit initialisation. Try it
> out..would work.
>
> Rishabh.
>
> -----Original Message-----
> From: Kalman Hazins [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 17, 2001 11:03 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JSP Counter
>
> Where should I initialize the variable ?????
>
> --- Kalman
>
> ----- Original Message -----
> From: "Rishabh Agarwal" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 16, 2001 9:08 PM
> Subject: Re: JSP Counter
>
>
> > Hi,
> >
> > In this case it helps to decalare the variable as
static.
> Also do not
> > initialise the variable in the page.
> >
> > Rishabh.
> >
> > -----Original Message-----
> > From: Sachin S. Khanna
> [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, May 16, 2001 12:57 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: JSP Counter
> >
> > One possible reason could be the
> restarting of the jvm on
> > mycgiserver.com
> > for some reason or the other and as far
as
> my experience
> > goes free servers
> > donot provide private jvm for every free
> account as it
> > doesnot make economic
> > sense because of which you could be
facing
> such a
> behaviour.
> > Hope this bit of info helps :-).
> > Have a nice day.
> > With regards,
> > Sachin S. Khanna
> > http://www.emailanorder.com
> > ----- Original Message -----
> > From: Kalman Hazins
<[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, May 16, 2001 8:33 AM
> > Subject: JSP Counter
> >
> >
> > > Hi, all. I have a small problem.
> > >
> > > I got some free webspace at
> www.mycgiserver.com and
> tried
> > practicing
> > writing
> > > a JSP counter.
> > >
> > > This was my code:
> > >
> > > <% out.println("This page has been
> accessed ") ; %>
> > > <%! int times = 0; %>
> > > <% out.println(times++ + " times") ;
%>
> > >
> > > So, it basically works. That is when I
> hit the "Refresh"
> > button the # of
> > > counts goes up. And sometimes even
when
> I close the
> > browser window and
> > > reopen it again --- it shows the right
> count... BUT...
> > every once in a
> > while
> > > I come back to the page ( a few hours
> later) and I see
> > that a lot of times
> > > the count starts from 0 again. What
can
> the problem be
> ???
> > >
> > > --- Kalman
> > >
> > > P.S. The page I created was
> www.mycgiserver.com/~Kalman
> > >
> > >
> >
> >
>
>
===========================================================================
> > > To unsubscribe: mailto
> [EMAIL PROTECTED] with body:
> > "signoff
> > JSP-INTEREST".
> > > For digest: mailto
[EMAIL PROTECTED]
> with body: "set
> > JSP-INTEREST
> > DIGEST".
> > > Some relevant FAQs on JSP/Servlets can
> be found at:
> > >
> > >
> http://java.sun.com/products/jsp/faq.html
> > >
> http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >
> >
> >
> >
>
>
===========================================================================
> > To unsubscribe: mailto
> [EMAIL PROTECTED] with body:
> > "signoff JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED]
> with body: "set
> > JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can
be
> found at:
> >
> >
http://java.sun.com/products/jsp/faq.html
> >
> http://www.esperanto.org.nz/jsp/jspfaq.html
> >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >
>
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
This email message is for the sole use of the intended recipient(s) and may
contain proprietary and confidential information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message. Thank you
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets