aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes pre compilation of JSP file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "pre compilation of JSP file" Watch "pre compilation of JSP file" New topic
Author

pre compilation of JSP file

Layla Rashid
Ranch Hand

Joined: Dec 25, 2006
Posts: 36
Hi
I am wondering if a container pre-compile a jsp file then does it avoid initialization and execution of _jspService method on the first request?

Thanks
Layla
Niteen Patil
Ranch Hand

Joined: Oct 27, 2009
Posts: 45
Hi Layla,

The jsp page life cycle is;
1. For the first request , the container translates and compiles the jsp file.
2.The container loads the newly generated servlet class.
3. The container instantiates the servlet and causes the servlets jspInit() method to run.
4. The container creates a new thread to handle the clients request and the servlets _jspService() method is called.

Translation and compilation happens only for the first request.
On subsequent requests, step 4 is executed.

Hope this helps.
Lorenz Baylon
Ranch Hand

Joined: Jan 04, 2006
Posts: 99
how about <load -on-startup> in the DD?


I just cant look, its killing me.
Niteen Patil
Ranch Hand

Joined: Oct 27, 2009
Posts: 45
I think <load -on-startup> should not disturb the call to jspInit() and _jspService() methods.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I think that <load-on-startup> causes that the first, the second and the third step are performed during deployment.
Step number 4 is performed during request.

Correct me if I am wrong.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Niteen Patil
Ranch Hand

Joined: Oct 27, 2009
Posts: 45
Lucas Smith you are correct.
If <load-on-startup> is set to a number greater than 0, then the created servlet is initialized on server startup.
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

So when you want to precompile JSP, you should modify your DD:

(you can add additional parameter for testing purposes - I observed interesting behaviour):



When I request front.jsp (using logical path) - email value is not reachable, but when I use mapping - everything is OK.
Please, remember that!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pre compilation of JSP file