File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Forcing JSP Recompile 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 » Java » Servlets
Bookmark "Forcing JSP Recompile" Watch "Forcing JSP Recompile" New topic

Forcing JSP Recompile

Pam Doucette

Joined: Mar 13, 2001
Posts: 27
I've run into a couple of instances when I've updated some java class files that will impact the jsps. However, the jsps themselves didn't need to be changed - and consequently were not re-compiled to show the impact of the other classes.
Is there a way to force a set of jsps to recompile besides deleting the class versions?
manav kher
Ranch Hand

Joined: Nov 21, 2000
Posts: 98
if you restart your container..JRUN/Apache etc that should do it. Since an instance of the class is created when a JSP is first called, if the scope is set to be session closing all the browser windows and then re-logging (effectively starting a new session) will also acheive what you intend to.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Pam Doucette:
Is there a way to force a set of jsps to recompile besides deleting the class versions?

There's a wonderful little unix program called "touch" which will update the timestamp on a file. There are gazillions of ports to Windows. All you'd have to do is create a little batch file which executes "touch *.jsp" in your JSP directory.
- Peter
Dustin Marx
Ranch Hand

Joined: Mar 06, 2001
Posts: 40
I too like "touch," but that approach does not work well with configuration management systems like Clearcase in which you would need to check-out each JSP as part of the batch file to "touch" it. So, in my case, I have found the easiest way to be to restart the web service, though sometimes I will also delete the entire classes directory to be certain the pages get recompiled.
It is sorta covered in the JavaRanch Style Guide.
subject: Forcing JSP Recompile