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

What values initialized in servlet

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).
 
Amit Vinod Dali
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GenericServlet with 2 init methods
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry still am not clear
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init() can be tipically called when the server starts or when the servlet is first called, before you handle the request. The server admin or the web application admin can confgure the moment in which method is called.

The only thing that you can count on is that init() is executed before the servlet executes its first request.

You are right, init() is usually called to perform servlet initialization.

About init(ServletConfig config): It's called by the container so you tipically should not override it.

As you can see from the documentation of GenericServlet class, the method init(ServletConfig config) receives the ServletConfig object config, that contains configuration information for your servlet



 
Fidel Edwards
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendra Prakash wrote:sorry still am not clear


Please Rajendra have a look here
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check the FAQ before posting questions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic