• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Initialization

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic