package cn.yzu;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class AServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletContext application=this.getServletContext();
Integer count=(Integer) application.getAttribute("count");
if(count==null)
{
count=1;
application.setAttribute("count",count);
}
else
application.setAttribute("count",++count);
PrintWriter writer=response.getWriter();
writer.print("<h1>"+count+"</h1>");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}