given this simple jsp counter, is there a way to store the counter information to a 
file/db so that it can be retrieved on server restart.

code:
<%
  Long hitCounter = (Long)application.getAttribute("hitCounter");
 if (hitCounter == null)
  hitCounter = new Long(0);
 hitCounter = new Long(hitCounter.longValue() + 1);
  application.setAttribute("hitCounter",hitCounter);
%>
<html>
<head>
<title>Hit Counter</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<div align="center">
  <pre><b><font size="+3" color="#0000FF">Hit Counter</font></b> </pre>
  <hr>
  This Page has been hit <font color="#FF3333"><b><%=hitCounter%></b></font> times.
  <hr>
  <form name="form1" method="post" 
action="<%=request.getContextPath()%>/web/hitcounter.jsp" >
    <input type="submit" name="Submit" value="Submit">
  </form>
</div>
</body>
</html>

thank you very much

alex

:   gʋ~&ܢfva _j 
(&

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

Reply via email to