Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jetty/Howto/Configure JSP"

< Jetty‎ | Howto
m
m
Line 20: Line 20:
 
|-
 
|-
 
| development
 
| development
| If <tt>development=true</tt>, recompilation checks are made on each request. See also <tt>modificationTestInterval</tt>
+
| If <tt>development=true</tt>, recompilation checks are made on each request. See also <tt>modificationTestInterval</tt>.
 
| TRUE
 
| TRUE
 
| -
 
| -
 
|-
 
|-
 
| fork
 
| fork
| Should Ant fork its java compiles of JSP pages.
+
| Should Ant fork its java compiles of JSP pages?
 
| TRUE
 
| TRUE
 
| FALSE
 
| FALSE
Line 45: Line 45:
 
|-
 
|-
 
| enablePooling
 
| enablePooling
| Determines whether tag handler pooling is enabled
+
| Determines whether tag handler pooling is enabled.
 
| TRUE
 
| TRUE
 
| -
 
| -
Line 55: Line 55:
 
|-
 
|-
 
| sendErrorToClient
 
| sendErrorToClient
| If false, stack traces etc are sent to std error instead of the clients browser
+
| If false, stack traces, etc., are sent to std error instead of the client's browser.
 
| FALSE
 
| FALSE
 
| -
 
| -
 
|-
 
|-
 
| classdebuginfo
 
| classdebuginfo
| Include debugging info in class file
+
| Include debugging info in class file.
 
| TRUE
 
| TRUE
 
| -
 
| -
 
|-
 
|-
 
| checkInterval
 
| checkInterval
| Interval in seconds between background recompile checks. Only relevant if <tt>development=false</tt>
+
| Interval in seconds between background recompile checks. Only relevant if <tt>development=false</tt>.
 
| 0
 
| 0
 
| -
 
| -
 
|-
 
|-
 
| suppressSmap
 
| suppressSmap
| Generation of SMAP info for JSR45 debugging
+
| Generation of SMAP info for JSR45 debugging.
 
| FALSE
 
| FALSE
 
| -
 
| -
 
|-
 
|-
 
| dumpSmap
 
| dumpSmap
| Dump SMAP JSR45 info to a file
+
| Dump SMAP JSR45 info to a file.
 
| FALSE
 
| FALSE
 
| -
 
| -
Line 85: Line 85:
 
|-
 
|-
 
| genStrAsByteArray
 
| genStrAsByteArray
| Option for generating Strings
+
| Option for generating Strings.
 
| TRUE
 
| TRUE
 
| -
 
| -
Line 119: Line 119:
 
|-
 
|-
 
| javaEncoding
 
| javaEncoding
| Pass through the encoding to use for the compilation
+
| Pass through the encoding to use for the compilation.
 
| UTF8
 
| UTF8
 
| -
 
| -
 
|-
 
|-
 
| modificationTestInterval
 
| modificationTestInterval
| If <tt>development=true</tt>, interval between recompilation checks, triggered by a request
+
| If <tt>development=true</tt>, interval between recompilation checks, triggered by a request.
 
| 0
 
| 0
 
| -
 
| -
 
|-
 
|-
 
| xpoweredBy
 
| xpoweredBy
| Generate an X-Powered-By response header
+
| Generate an X-Powered-By response header.
 
| FALSE
 
| FALSE
 
| FALSE
 
| FALSE
Line 139: Line 139:
 
|-
 
|-
 
| validating/enableTldValidation
 
| validating/enableTldValidation
| Whether or not to validate tag files against the schema
+
| Whether or not to validate tag files against the schema.
 
| FALSE
 
| FALSE
 
|
 
|
 
|-
 
|-
 
| reload-interval
 
| reload-interval
| If <tt>reload-interval=0</tt>, then no runtime checking of JSP, otherwise sets the checking interval for both <tt>development=true</tt> and <tt>development=false</tt>
+
| If <tt>reload-interval=0</tt>, then no runtime checking of JSP, otherwise sets the checking interval for both <tt>development=true</tt> and <tt>development=false</tt>.
 
|
 
|
 
|
 
|
 
|-
 
|-
 
| initial-capacity/initialCapacity
 
| initial-capacity/initialCapacity
| The initial capacity of the hash maps mapping the name of the JSP to class and JSP file
+
| The initial capacity of the hash maps mapping the name of the JSP to class and JSP file.
 
|
 
|
 
|
 
|
Line 177: Line 177:
 
</init-param>
 
</init-param>
 
</source>
 
</source>
<li>Do no checking whatsoever, but still compile the JSP on the very first hit. (Note: this "reload-interval" parameter is shorthand for a "development=false" and "checkInterval=0" combination):   
+
<li>Do no checking whatsoever, but still compile the JSP on the very first hit. (Note: this ''reload-interval'' parameter is shorthand for a ''development=false'' and ''checkInterval=0'' combination):   
 
<source lang="java">
 
<source lang="java">
 
<init-param>
 
<init-param>
Line 184: Line 184:
 
</init-param>
 
</init-param>
 
</source>
 
</source>
<li>Don't do any request-time checking, but instead start a background thread to do checks every N seconds (in the example below, every 60 sec):   
+
<li>Don't do any request-time checking, but instead start a background thread to do checks every N seconds. (This example checks every 60 seconds):   
 
<source lang="java">
 
<source lang="java">
 
<init-param>
 
<init-param>
Line 204: Line 204:
 
===Overriding webdefault.xml===
 
===Overriding webdefault.xml===
  
You can make a copy of the [[JETTY/webdefault.xml|webdefault.xml]] shipped with Jetty, apply your changes, and use it instead of the shipped version. The example below shows how to do this when using the Jetty Maven plugin.
+
You can make a copy of the [[Jetty/Reference/webdefault.xml|webdefault.xml]] shipped with Jetty, apply your changes, and use it instead of the shipped version. The example below shows how to do this when using the Jetty Maven plugin.
  
 
  <source lang="xml">
 
  <source lang="xml">
Line 219: Line 219:
 
</source>
 
</source>
  
If you're using Jetty standalone, and you want to change the JSP settings for just one or a few of your webapps, then copy the <tt>$JETTY_HOME/etc/webdefault.xml</tt> file somewhere, modify it, and then use a [[JETTY/ContextProvider|context xml]] file to set this file as the webdefaults for your webapp. Here's a snippet:
+
If you're using Jetty standalone, and you want to change the JSP settings for just one or a few of your webapps, then copy the <tt>$JETTY_HOME/etc/webdefault.xml</tt> file somewhere, modify it, and then use a [[Jetty/Feature/ContextDeployer|context xml]] file to set this file as the webdefaults for your webapp. Here's a snippet:
  
 
  <source lang="xml">
 
  <source lang="xml">
Line 235: Line 235:
 
===Configuring the JSP Servlet in web.xml===
 
===Configuring the JSP Servlet in web.xml===
  
Another option is to add an entry for the Jasper JSP servlet to the ''web.xml'' file of your webapp. You can use the entry in [/display/JETTY/webdefault.xml webdefault.xml] as a starting point.
+
Another option is to add an entry for the Jasper JSP servlet to the ''web.xml'' file of your webapp. You can use the entry in [[Jetty/Reference/webdefault.xml|webdefault.xml]] as a starting point.
 
   
 
   
 
  <source lang="xml">
 
  <source lang="xml">

Revision as of 16:26, 10 June 2011



Introduction

The JSP engine has many configuration parameters. Some parameters affect only precompilation, and some affect runtime recompilation checking. Parameters also differ between the 2.0 and 2.1 release of the JSP engine. This page lists the configuration parameters, their meanings and their default settings.

Important.png
Be careful
For all of the parameters below, if the value you set doesn't take effect, try using all lower case instead of camel case, as JSP is inconsistent in its parameter naming strategy.
Also be aware that for JDK1.6, the default for keepgenerated is false, therefore .java files will only be left after compilation if compilation error occurs.


Understanding JSP 2.1 Parameters

init param Description Default webdefault.xml
development If development=true, recompilation checks are made on each request. See also modificationTestInterval. TRUE -
fork Should Ant fork its java compiles of JSP pages? TRUE FALSE
keepgenerated Do you want to keep the generated Java files around? FALSE -
saveByteCode If class files are generated as byte arrays, should they be saved to disk at the end of compilations? FALSE -
trimSpaces Should white spaces between directives or actions be trimmed? FALSE -
enablePooling Determines whether tag handler pooling is enabled. TRUE -
mappedFile Support for mapped Files. Generates a servlet that has a print statement per line of the JSP file. TRUE -
sendErrorToClient If false, stack traces, etc., are sent to std error instead of the client's browser. FALSE -
classdebuginfo Include debugging info in class file. TRUE -
checkInterval Interval in seconds between background recompile checks. Only relevant if development=false. 0 -
suppressSmap Generation of SMAP info for JSR45 debugging. FALSE -
dumpSmap Dump SMAP JSR45 info to a file. FALSE -
genStrAsCharArray Option for generating Strings. FALSE -
genStrAsByteArray Option for generating Strings. TRUE -
defaultBufferNone FALSE -
errorOnUseBeanInvalidClassAttribute FALSE -
scratchDir

Directory where servlets are generated. Jetty sets this value according to the [/display/JETTY/Temporary+Directories work dir] settings for the webapp.

- -
compiler Determined at runtime. For Jetty this is the eclipse jdt compiler.
compilerTargetVM Target vm to compile for. 1.5 -
compilerSourceVM Sets source compliance level for the jdt compiler. 1.5 -
javaEncoding Pass through the encoding to use for the compilation. UTF8 -
modificationTestInterval If development=true, interval between recompilation checks, triggered by a request. 0 -
xpoweredBy Generate an X-Powered-By response header. FALSE FALSE
usePrecompiled/use-precompiled FALSE -
validating/enableTldValidation Whether or not to validate tag files against the schema. FALSE
reload-interval If reload-interval=0, then no runtime checking of JSP, otherwise sets the checking interval for both development=true and development=false.
initial-capacity/initialCapacity The initial capacity of the hash maps mapping the name of the JSP to class and JSP file.


Much confusion generally ensues about the development, checkInterval and modificationTestInterval parameters and JSP runtime recompilation. Here is a factoring out of the various options:

  1. Check the JSP files for possible recompilation on every request:
    <init-param>
            <param-name>development></param-name>
            <param-value>true></param-value>
    </init-param>
  2. Only check approximately every N seconds, where a request will trigger the time-lapse calculation. This example checks every 60 seconds:
    <init-param>
            <param-name>development></param-name>
            <param-value>true></param-value>
    </init-param>
    <init-param>
            <param-name>modificationTestInterval></param-name>
            <param-value>60></param-value>
    </init-param>
  3. Do no checking whatsoever, but still compile the JSP on the very first hit. (Note: this reload-interval parameter is shorthand for a development=false and checkInterval=0 combination):
    <init-param>
            <param-name>reload-interval></param-name>
            <param-value>-1></param-value>
    </init-param>
  4. Don't do any request-time checking, but instead start a background thread to do checks every N seconds. (This example checks every 60 seconds):
    <init-param>
            <param-name>development></param-name>
            <param-value>false></param-value>
     </init-param>
     <init-param>
             <param-name>checkInterval></param-name>
             <param-value>60></param-value>
    </init-param>


Modifying the Configuration

There are several options for modifying the Jasper JSP servlet configuration.

Overriding webdefault.xml

You can make a copy of the webdefault.xml shipped with Jetty, apply your changes, and use it instead of the shipped version. The example below shows how to do this when using the Jetty Maven plugin.

  <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <configuration>
    <webAppConfig>
      <defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
    </webAppConfig>
    <connectors>
    ..

If you're using Jetty standalone, and you want to change the JSP settings for just one or a few of your webapps, then copy the $JETTY_HOME/etc/webdefault.xml file somewhere, modify it, and then use a context xml file to set this file as the webdefaults for your webapp. Here's a snippet:

 <Configure class=>"org.eclipse.jetty.webapp.WebAppContext">
 
   <Set name=>"contextPath">/foo</Set>
   <Set name=>"war"><SystemProperty name=>"jetty.home" >default=>"."/>/webapps/foobar.war</Set>
   <Set name=>"defaultsDescriptor">/home/smith/dev/webdefault.xml</Set>
 
 </Configure>

If you want to change the JSP settings for all of the webapps, then edit the $JETTY_HOME/etc/webdefaults.xml file directly instead.

Configuring the JSP Servlet in web.xml

Another option is to add an entry for the Jasper JSP servlet to the web.xml file of your webapp. You can use the entry in webdefault.xml as a starting point.

 <servlet id=>"jsp">
     <servlet-name>jsp</servlet-name>
     <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
     <init-param>
         <param-name>logVerbosityLevel</param-name>
         <param-value>DEBUG</param-value>
     </init-param>
     <init-param>
         <param-name>fork</param-name>
         <param-value>>false</param-value>
     </init-param>
     <init-param>
         <param-name>keepgenerated</param-name>
         <param-value>>true</param-value>
     </init-param>
     ...
 
     <load-on-startup>0</load-on-startup>
   </servlet>
 
   <servlet-mapping>
     <servlet-name>jsp</servlet-name>
     <url-pattern>*.jsp</url-pattern>
     <url-pattern>*.jspf</url-pattern>
     <url-pattern>*.jspx</url-pattern>
     <url-pattern>*.xsp</url-pattern>
     <url-pattern>*.JSP</url-pattern>
     <url-pattern>*.JSPF</url-pattern>
     <url-pattern>*.JSPX</url-pattern>
     <url-pattern>*.XSP</url-pattern>
   </servlet-mapping>
 
   <servlet id=>"my-servlet">
     <servlet-name>myServlet</servlet-name>
     <servlet-class>com.acme.servlet.MyServlet</servlet-class>
      ...

Back to the top