YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.***w3.org/TR/REC-html40/loose.dtd">
第一步:我们要编写一个Servlet的代码,我编写一个记录访问网站次数的Servlet,代码如下:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class hitcountServlet extends HttpServlet
{
public void init(ServletConfig config)
throws ServletException
{
//The ServletConfig object must be passed to the super class
super.init(config);
}
// A counter to keep track of the number of users visiting the website
static int count;
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
count++;
out.println("");
out.println("