my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Translation and compilation happens only once in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Translation and compilation happens only once in a JSP" Watch "Translation and compilation happens only once in a JSP" New topic
Author

Translation and compilation happens only once in a JSP

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
"When you deploy a web app with a JSP, the whole translation and compilation step happens only once in the JSP's life. " What happens when we change the JSP code ?
Rohan kanade
Ranch Hand

Joined: Oct 22, 2009
Posts: 106
it is retranslated and recompiled.


SCJP 1.6 ,SCWCD 5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

When we change the code of a JSP page, the container can check the changes to the JSP and recompile it. The time interval after which the container checks for changes in the JSP is configurable in the container generally. Like in tomcat if you go under conf directory and open web.xml in it, you can configure the time interval through checkInterval initialization parameter to org.apache.jasper.servlet.JspServlet...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 272

I have a related question if that's OK.

If you make a change to a servlet, you have to redeploy your web application for the changes to take effect. If you make a change to a JSP, you don't need to redeploy. However, JSPs are servlets, so why do they differ in this way? Why do you have to redeploy your app when you make a change to a servlet, but don't have to redeploy your app when you make a change to a JSP?


SCJP 6 || SCWCD 5
Rohan kanade
Ranch Hand

Joined: Oct 22, 2009
Posts: 106
Because , the .jsp extension is handled by the container which has a parser and jsp engine, which looks at the last modified time of the jsp, and it translates and compiles it on the fly.

where as servlets are not handled by the container in that way.
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 272

Yes, I was just wondering why it can't do the same thing with servlet .class files. Like, check to see if the class file was updated when the servlet is called and reload it if it was. It probably has something to do with the servlets being in the classpath and not being files like JSPs or something.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Some containers, such as Tomcat, have an option to reload the web app if a servlet changes. But monitoring the classpath is expensive, so it's only recommended for development systems and not production.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Translation and compilation happens only once in a JSP
 
Similar Threads
JSP Compilation and Translation doubt
Life cycle of jsp?
Translation Phase of JSP - Doubt
Translation and compilation happens only ONCE page:308 HFSJ
jsp page translation