wood burning stoves 2.0*
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
Author

Servlet count

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
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.
Thanks,
Raju
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20542
    ∞

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
tony.b
Greenhorn

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet count