• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet count

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 21387
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
tony.b
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic