File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes JSP Deployment using Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JSP Deployment using Tomcat" Watch "JSP Deployment using Tomcat" New topic

JSP Deployment using Tomcat

ranjiith s

Joined: Dec 12, 2003
Posts: 8
Our application consists of a few hundred jsp files and not many in
them have any code logic in it.
To make the first request faster I was of the opinion to ship
pre-compiled jsps. But I have a Question.
Which is to be followed / best option?
- precompile the jsps and dump it in the work directory ?
- go as per tomcat docs (make entries in the web.xml for each of
the jsp file in your webapp)
- do not ship pre-compiled jsps and compile it as part of tomcat startup
Pramod Tiwari

Joined: Dec 13, 2011
Posts: 6

same problem i am also facing.

I created war file and upload to tomcat/webapps folder but when open any page at that time jsp file will compile (created *.java and *.class file).
But i want to do When War file Compile at tomcat startup at that time want to compile all jsp files.

If anybody have solution please tell me. i tried lots of method but still did not find any way.

Thanking you !!!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17247

That would be a violation of the J2EE spec. The actual code generated/compiled from JSPs is up to the server and there's no guarantee that a WAR containing pre-compiled JSPs for Tomcat would run under IBM WebSphere, for example. You may say "But I'm ONLY going to ever run it under Tomcat", but that's like saying I'm ONLY going to run it on Windows. Standards don't work that way. In fact, there's not even a guarantee that JSPs compiled for one version of Tomcat will work without recompiling if you switched to another version of Tomcat.

If you specified compile-on-startup and you had a WAR containing 1000 JSPs, of course, you'd probably see a massive internal denial of service which your CPUs all caught fire doing all that work in a short period of time. Then again, there's something wrong with a single webapp even needing 1000 different JSPs. If you have a a dozen or 2 JSPs, then pre-compiling at webapp deployment time is more reasonable. But it doesn't take that long to compile a JSP, so I normally let the default compile-on-demand mechanism handle it. Unless most of those JSPs are requested within milliseconds of startup, it spreads the work over time the same way distributed garbage collection does and the performance hit is transitory.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: JSP Deployment using Tomcat
It's not a secret anymore!