I Want To See My JSP's Generated Servlet Source!!

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...

Background:

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

   <servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
      <param-name>keepgenerated</param-name>
      <param-value>true</param-value>
   
</init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>

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:

your-domain-dir/generated/jsp/j2ee-modules\\YourModule/org/apache/jsp

___________________________

In summary:

(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!" 

Comments:

i want to see my e-mail

Posted by PANOS on April 03, 2008 at 11:16 PM PDT #

good comment if you want to meet me my adress is nick.powell@britishcounsil.org.np

Posted by kshitiz on November 03, 2008 at 01:26 PM PST #

Hi ,

I have a converged application deployed in sailfin b54.

When i make any configuration changes in DD sip.xml, say for ex. when i change values of init-param (SIP servlet), I can see that the changes are applied after i restart the sailfin server. but when i make any changes to web.xml ini-param (HTTP servlet), after restarting sailfin server, the updated values is not available. If I look at the DD web.xml through the Admin console of sailfin, its carrying the updated values. I was wondering if there is any tweaking that needs to be done to get this working.

Posted by inba on January 06, 2009 at 11:02 AM PST #

You can see your generated JSP Servlet source in the following path if you deploy your project in Apache Tomcat:
<Tomcat Installed Directory>\work\Catalina\localhost\_\org\apache\jsp.
For more information visit http://myjavaswtech.blogspot.in/

Posted by guest on May 21, 2012 at 09:58 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today