tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Bathje <>
Subject Re: dynamically compile JSPs
Date Mon, 10 Jan 2005 22:28:08 GMT wrote:
> Usage of the JspC class.  This should be what you want.
> I work in Windows 95% of the time, and I'm a simplicity freak, so I tend do do things,
most of the time, with batch files called from UltraEdit.  Anyway, this is relevant because
one of the steps in my typical build process is a compilation of all JSP's.  I use this class
to do that.  I can give you the two lines from my batch file that does this if it would be
helpful, but I tend to think the javadocs will get you where you want to go.

This is kind of an old thread I'm replying to - but I implemented what I 
thought would work for this, and haven't been able to get anything 
working reliably. As a refresher, the scenario is this:
- a Tomcat 5.0.x server with Jasper setup in development=false mode
- I upload a jsp page through a web interface, and want it to be 
compiled/usable immediately, instead of waiting for the scheduled jasper 
- putting ?jsp_compile=true on the page doesn't seem to work
- making development=true isn't an option

After looking through the JspC documentation a little bit, I tried this 
code in my class after the JSP file is uploaded:

JspC antTask = new JspC();
antTask.setArgs(new String[] { uploadTileFilePath });

And this does not seem to compile the file reliably. It does seem like 
something is happening, because the "upload/compile" action takes about 
25-30 seconds longer to load when the jsp compilation code is included. 
In my work directory, the .java and .class files are never updated (new 
time stamp) right away.

Sometimes if I wait a bit (5-10 minutes) the files are updated properly, 
but this seems to be the normal scheduled compilation.

Sometimes if I load the page up in a browser after it has been 
uploaded/"compiled", it seems to be compiled on access, but this does 
not always happen.

I was messing around with the code a little bit, and tried this:

JspC antTask = new JspC();
antTask.setArgs(new String[] { "-compile", uploadTileFilePath });

but this always gave me an error that javax.servlet package could not be 

I then tried:

JspC antTask = new JspC();
antTask.setArgs(new String[] { uploadTileFilePath });
antTask.setArgs(new String[] { "-compile", uploadTileFilePath });

and this seemed to make it (so far) that the JSP page always gets 
compiled the next time it is loaded in a browser.

This is passable if it must be the solution, but what I would really 
like is that the file gets completely compiled during the upload/compile 
action. The reason for this is that I want the person uploading to have 
to deal with the extra processing time, and not the person loading the page.

Any help with solving this problem would be greatly appreciated.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message