This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP Life Cycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP Life Cycle" Watch "JSP Life Cycle" New topic
Author

JSP Life Cycle

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 219

Head First Book:Please refer diagram on page no 307 .

Step 5: The continer inistantiates the servlet and causes the servlet's jspInit() method to run.

In diagram the container is calling jspInit() on myJSP_jsp and then this object becomes servet ie(myJSP_jsp) which then ready to handle the client request.

Q1)I am confused,I think the container must call _jspInit().Because if we see the generated source code there is no jspInit().

Q2)On page no:305 it is written that jspInit():This method is called from init().If we compared this statement with diagram in step no5
servlet is getting generated after calling jspInit().So how can init() can call jspInit()?




Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Q1) JSPs must implement the HttpJspPage interface, which extends the JspPage interface, which defines jspInit and jspDestroy methods. The container must call jspInit(). What you are looking at is a container generated class implementing HttpJspPage. If you are using Tomcat, the class is org.apache.jasper.runtime.HttpJspBase, which implements HttpJspPage.

Q2) The servlet is not generated after calling jspInit. It is generated during the translation phase. There, your JSP becomes a servlet. The first time it is instanciated, its init() method will be called, which in turn will call the jspInit() method.


[My Blog]
All roads lead to JavaRanch
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: JSP Life Cycle
 
It's not a secret anymore!