SOURCE CODE:
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class hello extends HttpServlet
{
privateint visits=0;
public void doGet (HttpServletRequestrequest,HttpServletResponse response)
throwsServletException,IOException
{
response.setContentType("text/html; charset=\"UTF-8\"");
PrintWriterservletOut=response.getWriter();
visits++;
servletOut.println(
"<!DOCTYPE html \n"+
"PUBLIC \"-//w3c//DTD XHTML1.0 Strict//EN\" \n"+
"\"http://www.w3.org/TR/xhtml!/DTD/xhtml!-strict.dtd\"> \n"+
"<html xmlns='http://www.w3.org/1999/xhtml'> \n"+
"<head> \n"+
"<title> \n"+
"HelloCounter.java \n"+
"</title> \n"+
"</head> \n"+
"<body> \n"+
"<p> \n"+
"hello world! \n"+
"</p> \n"+
"<p>\n"+
"this page has been viewed \n"+
visits+
"times since the most recent server restart.\n"+
"</p>\n"+
"</body> \n"+
"</html>");
servletOut.close();
}
}
No comments:
Post a Comment