import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ShowTimesServlet extends HttpServlet {
private static final long serialVersionUID =1L;
protected void doGet(HttpServletRequest request,
HttpServletResponse response ) throws ServletException, IOException{
ServletContext context = getServletContext();
integer times =(integer) context.getAttribute("times");
if(times==null ){
times=new = Integer(1);}
else{times=new Integer(times.intValue()+1);}
response.setContenType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
out.println("<html><head><title>");
out.println("网页访问统计");
out.println("</title></head><body>");
out.println("当前网页被访问了");
out.println("<font color=red size=20>"+times+"</font>次")
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException , IOException{
this.doGet(request,response);}
}
版权声明:本文为RorZoro原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。