A Holistic counter in Servlet
In this program we are going to make a such a servlet which will count the number it has been accessed and the number of threads created by the server.
In this example firstly we are going to create one class named as HolisticCounterInServlet. Now declare a variable counter of int with initial value 0, the value of this counter will be different for each servlet and create a Hashtable object. This object will be shared by all the threads in the container. Inside the doGet() method use the method getWriter() method of the response object which will return the PrintWriter object.
The code of the program is given below:
import java.io.*;
|
The output of the program is given below: