Precompile JSP
From Resin 3.0
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]
Attribute | Description | Type | Default |
---|---|---|---|
extension | An extension to precompile | String | jsp |
fileset | A fileset for complex matching | FileSetType | none |
timeout | The time to wait for compilation to complete | Period | 60s |
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
<web-app-default> <listener> <listener-class>com.caucho.jsp.JspPrecompileListener</listener-class> </listener> </web-app-default>
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.