/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("调用doGet");
Date now=new Date();
SimpleDateFormat format=new SimpleDateFormat("yyyy年MM月dd日");
//解决中文乱码
response.setContentType("text/html;charset=GBK");
//会话跟踪 创建Session
HttpSession session=request.getSession(true);
// session.setAttribute("counter",new Integer(counter));
Object count=session.getAttribute("counter");
int counter=0;
if(count==null){
System.out.println("这也运行了");
counter=1;
session.setAttribute("counter", new Integer(1));
}else{
System.out.println((Integer)count);
System.out.println(counter);
counter=((Integer)count).intValue();
counter++;
session.setAttribute("counter", new Integer(counter));
System.out.println(counter);
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("调用doPost()");
doGet(request, response);
}
/**
* 调用父类的构造方法
*/
public HelloServlet(){
super();
}
/**
* servlet初始化
*/
// public void inint() throws ServletException(){
// System.out.println("初始化时,init()方法被调用");
// }
public void init() throws ServletException{