aspose file tools*
The moose likes Servlets and the fly likes Servlet init() and service() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet init() and service()" Watch "Servlet init() and service()" New topic
Author

Servlet init() and service()

S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Hi every body, I have a query :

Can I call service() under the init() ?
Can I call init() under service() ?

regards,
S
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

They're just methods, you can do anything you want. Whether it's completely silly or not (hint: yes) is another matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Thanks Bear Bibeault ,
for your reply ,
so suppose I am calling service() under init() what will happen ?
suppose I am calling init() under service() what will happen ?

regards,
S
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

It's just Java. Whatever code is in the methods will execute. It'd be a completely silly thing to do, but nothing prevents you from being silly.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41865
    
  63
In other words, nothing special will happen, in particular, the servlet will not be initialized (if that's what you expected to happen). Initialization doesn't happen because the init() method is called - the init() method is called because the servlet is initialized (which is something the servlet container does, not your servlet code).


Ping & DNS - my free Android networking tools app
lianchi gao
Greenhorn

Joined: May 12, 2007
Posts: 7
Ulf Dittmer wrote:In other words, nothing special will happen, in particular, the servlet will not be initialized (if that's what you expected to happen). Initialization doesn't happen because the init() method is called - the init() method is called because the servlet is initialized (which is something the servlet container does, not your servlet code).


i think he is right, because you can't control the servlet container.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

lianchi gao wrote:i think he is right

No thinking needed -- he's exactly right.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet init() and service()