Write a JAVA program using servlet to count the no of times a servlet has been invoked.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


    public class slip24 extends implements
    {

    static int numreq=0;
    proctected void doGet(ServletRequest reg,ServletResponse res)

    throws ServletException,IOException
    {
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    out.println("Servlet invoke :");
    numreq++;
    out.println("numreq");
    out.close();

    }
}

3 comments:



  1. Great breakdown! I’ve been looking for a well-structured explanation of Servlet architecture for a while, and this finally hit the spot. Specifically, the distinction between workflows vs projects made it click for me. Thanks for the clarity, awesome work!.

    ReplyDelete

  2. Very informative and well-explained tutorial.The servlet-tutorial concepts are easy to understand, and the examples are helpful for beginners.Great learning resource Learn servlet-tutorial.

    ReplyDelete