Precompile JSP
From Resin 3.0
(New page: Category: Config Category: Performance Unless explicitly compiled ahead of time, JSP files are compiled the first time they are accessed. On large production sites, or in situatio...) |
|||
Line 1: | Line 1: | ||
− | [[Category: Config]] | + | [[Category: Config]] [[Category: Performance]] |
− | [[Category: Performance]] | + | |
Unless explicitly compiled ahead of time, JSP files are compiled the first time they are accessed. On large production sites, or in situations involving complicated JSP files, compilation may cause unacceptable delays to users first accessing the JSP page. | Unless explicitly compiled ahead of time, JSP files are compiled the first time they are accessed. On large production sites, or in situations involving complicated JSP files, compilation may cause unacceptable delays to users first accessing the JSP page. | ||
− | Resin provides | + | Resin provides JspPrecompileListener that causes JSP to be compiled when the web application starts. |
+ | |||
== JspPrecompileListener == | == JspPrecompileListener == | ||
+ | |||
+ | javadoc: [[http://www.caucho.com/resin-4.0-javadoc/com/caucho/jsp/JspPrecompileListener.html]] | ||
The following configuration causes Resin to compile all files in the web-app that have an extension of .jsp or .jspx when the application first starts. | The following configuration causes Resin to compile all files in the web-app that have an extension of .jsp or .jspx when the application first starts. |
Revision as of 18:58, 9 December 2011
Unless explicitly compiled ahead of time, JSP files are compiled the first time they are accessed. On large production sites, or in situations involving complicated JSP files, compilation may cause unacceptable delays to users first accessing the JSP page.
Resin provides JspPrecompileListener that causes JSP to be compiled when the web application starts.
JspPrecompileListener
javadoc: [[1]]
The following configuration causes Resin to compile all files in the web-app that have an extension of .jsp or .jspx when the application first starts.
WEB-INF/web.xml
<web-app xmlns="http://caucho.com/ns/resin"> <listener> <listener-class>com.caucho.jsp.JspPrecompileListener</listener-class> <init> <extension>jsp</extension> <extension>jspx</extension> </init> </listener> </web-app>
It can also be configured in resin.xml to apply to all web-apps.
resin.xml </pre> <web-app-default>
<listener> <listener-class>com.caucho.jsp.JspPrecompileListener</listener-class> </listener>
</web-app-default> </pre> You can also use a <fileset> for more control over which jsp are precompiled:
resin.xml
<web-app> <listener> <listener-class>com.caucho.jsp.JspPrecompileListener</listener-class> <init> <fileset> <include>**/*.jsp</include> <exclude>/a.jsp</exclude> <exclude>/foo/c.jsp</exclude> </fileset> </init> </listener> </web-app>
The first line includes all jsp's, it's the same as specifying jsp. The following lines exclude specific jsp.
JSPC
As an alternative, Resin also provides a jspc command line that is used to explicitly compile JSP files before they are accessed for the first time.
Command line
unix> ./bin/resin.sh jspc usage: com.caucho.jsp.JspCompiler [flags] jsp1 jsp2 ... -app-dir : The directory root of the web-app. -class-dir: The working directory to use as output. -compiler: sets the javac. -conf: A configuration file for the compiler.