• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Initialization

 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Well can you tell me that in how many ways can we initialize the Servlet?
Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is really too vague for an answer. What do you mean by it?

On one hand, there are two different methods you could override (technically, two overloads of the same method). So maybe the answer is two.

On the other hand, you can write virtually anything you want within those methods, so maybe the answer is an infinite number.

Perhaps you can clarify your question?
 
prash patil
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kayanaat,
If you asking this question in context with initializing servlet can be possible other than init() method, then
Check this link .. May this can help you.
Initialize servlet

Regards,
PP.
 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bear Bibeault ,
I just got this question during my interview, same as written. So according to you what would be the answer?
Now, is there any way to initialize the srvlet other than init method?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspected it was a silly interview question.

You could create a constructor, but that's a poor way to perform initialization as the ServletConfig instance is not available. Perhaps that's what the interviewer was fishing for.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!