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 ? (or) - go as per tomcat docs (make entries in the web.xml for each of the jsp file in your webapp) (or) - do not ship pre-compiled jsps and compile it as part of tomcat startup
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.
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.