File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet count Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet count" Watch "Servlet count" New topic

Servlet count

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can i keep track of how many times a servlet is invoked??
If i have todo some initialisation if the servlet is invoked for the first time ,then how can i do it.
paul wheaton

Joined: Dec 14, 1998
Posts: 20965

I do this as sort of a debugger. All you need to do is make a claas attribute called count and in your doGet put count++; count now hold the number of hits.

permaculture Wood Burning Stoves 2.0 - 4-DVD set

Joined: Mar 02, 2002
Posts: 4
Hi raju,
If you want to do some sort of initialization when servletis invoked for the first time, then you have to override init() or init(ServletConfig) method. If you will override simple init() then you don't need to worry about servletConfig object. If you will override init(ServletConfig) then you have to save that parameter or just call super.init(ServletConfig) by passing the object which you got.
I agree. Here's the link:
subject: Servlet count
It's not a secret anymore!