|
INTERVIEW QUESTIONS
J2EE
SERVLET
DETAILS
Question: How the server will know (i.e) when it can invoke init, service,destroy methods of servlet life cycle?
Answer: When a request for a servlet is made the container will check for the servlet instance 1. If an instance of the servlet does not exist, the web container 1. Loads the servlet class. 2. Creates an instance of the servlet class. 3. Initializes the servlet instance by calling the init() method. 2. Invokes the service() method, passing request and response objects. 3. If the container needs to remove the servlet, it finalizes the servlet by calling the servlet's destroy() method.
|
|
|
Category |
Servlet Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8791 users |
Added on |
7/17/2011 |
Views |
68125 |
Rate it! |
|
|
Question:
How the server will know (i.e) when it can invoke init, service,destroy methods of servlet life cycle?
Answer:
When a request for a servlet is made the container will check for the servlet instance 1. If an instance of the servlet does not exist, the web container 1. Loads the servlet class. 2. Creates an instance of the servlet class. 3. Initializes the servlet instance by calling the init() method. 2. Invokes the service() method, passing request and response objects. 3. If the container needs to remove the servlet, it finalizes the servlet by calling the servlet's destroy() method. Source: CoolInterview.com
In brief only container will decide when call servlet life cycle method. Source: CoolInterview.com
Answered by: Gaurav Gupta | Date: 10/16/2009
| Contact Gaurav Gupta
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What method used to add a jsp to the servlet
|
View Answer
|
|
What is the need of super.init(config) in servlets?
|
View Answer
|
|
What is the importance of deployment descriptor in servlet?
|
View Answer
|
|
What methods will be called in which order? ((i.e)service(),doget(),dopost())
|
View Answer
|
|
When you have action=get?
|
View Answer
|
|
Can a init(ServletConfig config) method be overrided in servlets?
|
View Answer
|
|
Is servlet is used to create a dynamic webpage or Static webpage or both?
|
View Answer
|
|
We have two applications in that we have two servlets each.How they(servlets) communicate with each other ?
|
View Answer
|
|
How will u pass the argument from one servlet to another servlet?
|
View Answer
|
|
What is the super class of All servlets?
|
View Answer
|
|
Types of Servlets?
|
View Answer
|
|
I want to know how to encode textbox in servlet so we find complete column information from the database
|
View Answer
|
|
What are the JSP atrributes?
|
View Answer
|
|
How much amount of information will be stored within a session
|
View Answer
|
|
Suppose in web.xml file we are given 30 and in the servlet program we are given setSessionInActiveInterval(40).when that session will be terminated ? After 30 sec or 40 sec?
|
View Answer
|
|
In which conditions we have to use the ServletContext
|
View Answer
|
|
How we can check in particular page the session will be alive or not?
|
View Answer
|
|
How to get value from init() method in servlet? or How to get initializaion time values from init() in servlet
|
View Answer
|
|
How to get initialization time (init () method)values in servlet?
|
View Answer
|
|
In servlets, what is the use of sendredirect(),include( ), forward() ?and in applecation level at what scnario they will be used
|
View Answer
|