Counter.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Counter extends HttpServlet {

    int counter = 0;
    
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
	
	// Increment the counter each time the page is accessed
	counter++;
	
	res.setContentType("text/html");
	PrintWriter out = res.getWriter();
	
	out.println("<HTML>");
	out.println("<HEAD><TITLE>Counter Servlet</TITLE></HEAD>");
	out.println("<BODY>");
	out.println("This page has been accessed " + counter + " times");
	out.println("</BODY></HTML>");
    }
}

Generated by GNU enscript 1.6.4.