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...
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 areservlets, 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
Joined: Oct 22, 2009
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.
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.
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.