File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on Jsp methods that are invoked by servlet container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt on Jsp methods that are invoked by servlet container" Watch "Doubt on Jsp methods that are invoked by servlet container" New topic
Author

Doubt on Jsp methods that are invoked by servlet container

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi,
Select the correct order that JSP methods are invoked by servlet container. Please select one correct answer.
A. jspInit(),jspService,jspDestroy()
B. jspInit(),_jspService,jspDestroy()
C. _jspInit(),jspService,_jspDestroy()
D. _jspInit(),_jspService,_jspDestroy()

Answer:B

Source: JavaBeat.com

Can anybody tell as to why the answer is B.
With regards,
Padma priya N.G.


Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Priya,

Did you gone thropugh the lifeCycle of JSP ?

Those are first steps learning JSP.

I think you learning from the Questions
instead of reading the book and giving exams.

This is not correct.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi Srinivasan,
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.
With regards,
Padma priya N.G.
Arnab Sinha
Ranch Hand

Joined: Jul 23, 2006
Posts: 72
Originally posted by padmapriyagururajan priya:
Hi Srinivasan,
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.
With regards,
Padma priya N.G.


Hello Padma,

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.

Arnab


SCJP 1.4: 91%<br />SCWCD 1.4: 85%
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Priya,

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:

JspPage, HttpJspPage

A look at each

public interface JspPage
extends javax.servlet.Servlet

Methods:

void jspDestroy()

The jspDestroy() method is invoked when the JSP page is about to be destroyed.

void jspInit()
The jspInit() method is invoked when the JSP page is initialized.


public interface HttpJspPage
extends JspPage

Methods:

void _jspService(
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
_jspService()
jspInit()
jspDestroy()
and
init()
service()
destroy() and remaining servlet interface methods;


Now
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
see this:

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 ]
Prafulla N. Patil
Ranch Hand

Joined: Mar 20, 2006
Posts: 106
I think you are not gone fully through HFSJ
that is why you are coming with such type of doubts
be patient, take some time to study book fully

Best Luck


Thanks, Prafulla Patil
SCJP, SCWCD
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi Srinivasan,
Thanks. I have started going through HFSJ.
With regards,
Padma priya N.G.
Frederic Thierry
Greenhorn

Joined: Dec 19, 2006
Posts: 4
Srinivasan you are totally. Priya just look into the HFSJ book and you will find most answers to your questions.
 
 
subject: Doubt on Jsp methods that are invoked by servlet container
 
Similar Threads
jsp translate servlet method problem
jspInit() problem
Translation phase
jspInit() or jsp_init()?
review question chap 9.