I Want To See My JSP's Generated Servlet Source!!
By ByronNevins on Nov 13, 2007
It is difficult to see the servlets that get generated from your JSP files.
If you politely ask NetBeans it will tell you something like "You have to run the file first". And this is after you run the file!
Anyways once you know how -- it is easy. Read on...
When you deploy a web module (or a Web App that has a web module in it) by default it will not compile the jsp's as part of the deployment process. Instead, the jsp will be compiled "just in time" by the web container the first time the web module is accessed long after deployment completes.
We need to tell the jsp-compiler to keep the generated files instead of deleting them. This is the "keepgenerated" option to the jsp-compiler. You set this option by editing the default-web.xml file in the domain's config directory. Search for "keepgenerated" and you will see the xml that needs editing just below the enormous comment. It should look like this when you're done editing
You would think that that is enough to get your generated source, but it is not. The web-container orchestrated jsp compile is either ignoring the keepgenerated option -- or the generated files are well-hidden.
But it will work if you ask the GF Deployment code to do the compiling for you like so:
asadmin deploy --precompilejsp=true some.war
ALL of your jsp generated servlet source will be located in:
(1) setup the keepgenerated option in default-web.xml and then forget about it
(2) For every deployment use the --precompilejsp=true option
I spent far too much time figuring this out so I am sharing my results here.
As I was stepping through the deployment source code I thought "Wow, this is pretty nice code". Then I realized "HEY! I wrote this code! It's been about 5 years but there it still is!"