Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet init() and service()

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They're just methods, you can do anything you want. Whether it's completely silly or not (hint: yes) is another matter.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
lianchi gao
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lianchi gao wrote:i think he is right

No thinking needed -- he's exactly right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic