I have a hit counter servlet for each time my page is visited
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleCounter extends HttpServlet{
int counter = 0;
public void doGet(HttpServletRequest request, HttpServletResponse
response)throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
counter++;
pw.println("the number of times this page was visited:" + counter);
}
}
The part above for the hit counter works but i want to add a reset button.
I was thinking of a button in a form that will use post and go back to the same page and set the int counter = 0 again. how can i fix this part on the bottom or what is the right to add a reset button ?
pw.println("<form action="counter.java" method="post"> <input type="submit" value="reset"></form>");