Hey, I remember this thread :)
(Mostly because you quoted my comment!)
One solution is to "shell out" to do the compilation. I think I probably gave it to you last time, but here's the two pertinent lines from my compile job that does it:
java -classpath %CP% org.apache.jasper.JspC -v3 -die -d %JSPAppDir% -webapp %WebAppDir%
javac -classpath %CP% -d %JspDir% %JspDir%\*.java
...where...
%CP% is the classpath, inclduing servlet.jar %JSRDir% is the location of the JSP %WebAppDir% is something like c:\tomcat\webapps\myapp
(I modified this a tad so it's more applicable to you, but don't shoot me if you have to hack it slightly)
Now, what I'm thinking, AND I BY NO MEANS ENDORSE THIS AS A GOOD SOLUTION, is that you could shell out these two commands, and that I think would get the job done. This is a has a Windows skew to it of course, but I can't see any reason it wouldn't work under *nix, if that's your environment, which just some minor changes.
I've never tried using JspC from Java code as you did, although I'd think that's the way you'd want to go. I don't know what's wrong with the code you provided however, but if you get to that hair-pulling stage where you feel like your really stuck, I'm relatively sure the above will do it for you, if worse comes to worse. I guess if this isn't something that's going to be happening a lot, it might not be a problem this way.
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com
Matt Bathje wrote:
[EMAIL PROTECTED] wrote:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper/docs/api/index.html
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 compilation
- 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 }); antTask.execute();
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 }); antTask.execute();
but this always gave me an error that javax.servlet package could not be found.
I then tried:
JspC antTask = new JspC(); antTask.setArgs(new String[] { uploadTileFilePath }); antTask.execute(); antTask.setArgs(new String[] { "-compile", uploadTileFilePath }); antTask.execute();
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.
Thanks, Matt
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
