hit count
Fri Nov 15 2024 15:01:20 GMT+0000 (Coordinated Universal Time)
Saved by
@wtlab
package hitcount1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class count1
*/
@WebServlet("/count1")
public class count1 extends HttpServlet {
private static final long serialVersionUID = 1L;
//public int count;
public int count;
/**
* @see HttpServlet#HttpServlet()
*/
public count1() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see Servlet#init(ServletConfig)
*/
public void init(ServletConfig config) throws ServletException {
count=0;
// TODO Auto-generated method stub
}
/**
* @see Servlet#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
*/
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
//response.getWriter().append("Served at: ").append(request.getContextPath());
PrintWriter out =response.getWriter();
count++;
out.println("<h1> the count will be incremented </h1>");
out.println("<h1>count :"+count+"</h1>");
}
}
content_copyCOPY
Comments