Select the correct order that JSP methods are invoked by servlet container. Please select one correct answer.
Can anybody tell as to why the answer is B.
Padma priya N.G.
Originally posted by padmapriyagururajan priya:
According to me, the lifecycle of a jsp consists of init(), service() and destroy() methods. In the question given above, Init(),_Service() and Destroy() methods is chosen as the option. So, I am confused.
Padma priya N.G.
If you read the section on lifecycle of a jsp in HFSJ, you will notice the naming conventions. Answer B is correct because it is _jspService. Ans A is incorrect because of incorrect name. Hope this helps.
I think you might have derived it from people saying
"JSP is Servlet".
offcource it is but Go through this:
A JSP has to implement JSP ness and Servlet ness.
For that they came up with two interfaces which can satisfy both the needs:
A look at each
public interface JspPage
The jspDestroy() method is invoked when the JSP page is about to be destroyed.
The jspInit() method is invoked when the JSP page is initialized.
public interface HttpJspPage
javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
The _jspService()method corresponds to the body of the JSP page.
So the Jsp implementation(for HTTP) Shall contain
implementation for HttpJspPage[(JspPage,Servlet)-->implied)]
So it contains implementation for
destroy() and remaining servlet interface methods;
Coming to your point JSP is a servlet.
yes Now you know the implemention calss has all the above methods implemnted.
How the servlet methods invoking the Jsp mehtods
1. init() method calls jspInit()
2. service() method calls _jspService()
3. destroy method calls jspDestroy()
Like this Servletness and Jspness are fulfilled
[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]