• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pre compilation of JSP file

 
Layla Rashid
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about <load -on-startup> in the DD?
 
Niteen Patil
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think <load -on-startup> should not disturb the call to jspInit() and _jspService() methods.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Niteen Patil
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic