tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quoc Thao Nguyen" <quoc.thao.ngu...@zurich.ch>
Subject Re: servlet question !!
Date Fri, 09 Jun 2000 09:01:22 GMT

Helo

Servlet are loaded and instiantiaded only one time. So   int  count=0;
ist executed only one time.
The method    doGet    is executed often time, once per Client Request.
For each request to this servlet gets the  initial value of count i.e. 0,
put    count=0;    into this method at the beginning.

T.Nguyen






"Manpreet" <manpreetnagpal@yahoo.com> on 06.01.2000 19:47:53

Please respond to tomcat-user@jakarta.apache.org

To:   <tomcat-user@jakarta.apache.org>
cc:
Subject:  servlet question !!



HI all,

I have a small servlet code like this:

import java.io.*;
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();
             out.write(count++);
        }
}

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

thanks in advance ,
Manpreet Singh.








Mime
View raw message