File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init() method ........

 
eswar kumar
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i call servlet init() method from sevlet service() method ?
share with me
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EJB certification exam does not deal with servlets.
Therefore, I'm moving this thread to the Servlets forum where you might get more answers. Thank you
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing to stop you calling init() from service(), but one has to wonder why you would want to do so.
If you expect your servlet might be subclassed (particularly by a different developer) in the future, it would be wise to avoid calling init() from service() because this would surprise them and perhaps cause bugs.
 
deepak kukreja
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init() is used by the servlet container for initializing a servlet.
Even if u call it in ur code it won't do 'nething for you.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if u call it in ur code it won't do 'nething for you.

It will do whatever is coded in it, no? You might want a servlet to re-read configuration from a file or refresh a cache from the database so you don't have to stop and restart the server to affect changes. Even so, I'd make a method with a more meaningful name like loadFooCache() and call it from init() and from the refresh() call.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic