Skip to main content

[webtier] Re: Packaging JSP in JAR files

1 reply [Last post]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jan Luehe


On 09/15/08 09:10 AM, Jose Noheda wrote:
> Hi,
> Can I somehow precompile JSPs and pack them in a JAR file placed under
> WEB-INF in a way that glassfish understands it? What about a portable
> solution?

You can use the "jspc" utility, which has been available in GlassFish
v1/v2 and was recently ported to v3 (see, to
precomile your JSPs. You then package the
generated servlet class files in a JAR file, which you store in your
webapp's WEB-INF lib.

If you do not anticipate any modifications to your JSP files once they
have been precompiled, you have the option
of not including the JSP files with your webapp.

There are 2 ways of doing this:

- Have the "jspc" utility create mappings (one mapping per
JSP) in your web.xml, which will map a
request for a JSP directly to the corresponding servlet. You can ask
"jspc" to either generate the complete
web.xml file, or a web.xml snippet that contains all the

- If there are too many JSPs in your webapp, adding a mapping
for each may not be practical,
because of the size of the resulting web.xml. In this case, you can
still omit the JSP files from your webapp
if you set the "usePrecompiled" init-parameter of the JspServlet to
true. This can be done either globally
(in your domain's default-web.xml), or locally on a per-webapp basis
(in the webapp's sun-web.xml).

As a side note, please use "" for any
GlassFish webtier related questions going



To unsubscribe, e-mail:
For additional commands, e-mail: