// ShowTimesServlet. java/* example of the number of visits implemented by Servlet! */
Import java. io .*;
Import java.util.zip .*;
Import javax. servlet .*;
Import javax. servlet. http .*;
/*
The number of accesses implemented by this class. Show the number of visits! The number of visits!
*/
Public class ShowTimesServlet extends HttpServlet {
Public void doGet (HttpServletRequest request, HttpServletResponse response)
Throws ServletException, java. io. IOException {
Response. setContentType ("text/html ");
HttpSession session = request. getSession ();
String heading;
Integer access (favorite of small websites) Count = (Integer) session. getAttribute ("access (favorite of small websites) Count ");
If (access (favorite of small websites) Count = null ){
Access (favorite of small websites) Count = new Integer (0 );
Heading = "Welcom, You are first time to visit! ";
}
Else {
Heading = "Welcome Backer ";
Access (favorite of small websites) Count = new Integer (access (favorite of small websites) Count. intValue () + 1 );
}
Session. setAttribute ("access (favorite of small websites) Count", access (favorite of small websites) Count );
PrintWriter out = response. getWriter ();
Out. println ("The title:" + heading );
Out. println ("access (favorite of small websites) count:" + access (favorite of small websites) Count );
}
Public void doPost (HttpServletRequest request, HttpServletResponse response)
Throws ServletException, java. io. IOException {
DoGet (request, response );
}
}