tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Cook" <>
Subject Re: servlet question !!
Date Thu, 08 Jun 2000 13:00:04 GMT

Consider that there is one instance of this class living in the servlet
engine. The first request to this servlet will cause the servlet to be
initialized. Count will equal 0. The output will be count++, or 1.
Subsequent requests (by the same client or others) will continue to
increment count. This will return 2, 3, 4, etc.

BTW, the servlet is reentrant, meaning that one or more of these clients can
be in the servlet concurrently. It is possible that two clients hitting your
code could return the same output value.


----- Original Message -----
From: Manpreet <>
To: <>
Sent: Thursday, January 06, 2000 3:47 PM
Subject: servlet question !!

HI all,

I have a small servlet code like this:

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

public class Test extends HttpServlet {
        int count=0;
        public void doGet(HttpServletRequest req , HttpServletResponse res)
throws         IOException , ServletException {
            PrintWriter out=res.getWriter();

Is it possible that each request to this servlet gets the initial value of
count i.e. 0

thanks in advance ,
Manpreet Singh.

View raw message