The Jakarta Project
      The Tomcat Servlet/JSP Container

Links

Getting Started

Configuration

Administrators

Application Developers

Catalina Developers

Jasper Developers

Jasper 2 JSP Engine How To

Table of Contents

Introduction
Upgrading
Configuration
Production Configuration
Using Jikes

Introduction

Starting with Tomcat 4.1, Tomcat uses the Jasper 2 JSP Engine to implement the JavaServer Pages 1.2 specification.

Jasper 2 has been redesigned to significantly improve performance over the orignal Jasper. In addition to general code improvements the following changes were made:

  • JSP Custom Tag Pooling - The java objects instantiated for JSP Custom Tags can now be pooled and reused. This significantly boosts the performance of JSP pages which use custom tags.
  • Background JSP compilation - If you make a change to a JSP page which had already been compiled Jasper 2 can recompile that page in the background. The previously compiled JSP page will still be available to serve requests. Once the new page has been compiled successfully it will replace the old page. This helps improve availablity of your JSP pages on a production server.
  • Recompile JSP when included page changes - Jasper 2 can now detect when a page included at compile time from a JSP has changed and then recompile the parent JSP.
  • Ant used to compile JSP pages - The Ant Build Tool is now used to perform JSP java source code compilation.

Jasper is implemented using the servlet class org.apache.jasper.servlet.JspServlet.

Upgrading

Upgrading to Tomcat 4.1 and Jasper 2 from an earlier version of Tomcat and/or Jasper.

Jasper 2 generates different java source code from Jasper 1. You must remove all previous class files generated for your JSP pages from your work directory.

Jasper 2 implements JSP Custom Tag Pooling. This can cause JSP custom tags which are not compliant with the JSP specification to fail or behave inconsistently. When upgrading from a version of Tomcat earlier than 4.1 you should test to make sure your JSP pages which use custom tags are working correctly.

Configuration

By default Jasper is configured for use when doing web application development. See the section Production Configuration for information on configuring Jasper for use on a production Tomcat server.

The servlet which implements Jasper is configured using init parameters in your global $CATALINA_BASE/conf/web.xml.

  • checkInterval - If development is false and reloading is true, background compiles are enabled. checkInterval is the time in seconds between checks to see if a JSP page needs to be recompiled. Default 300 seconds.
  • compiler - Which compiler Ant should use to compile JSP pages. See the Ant documenation for more information. Default javac.
  • classdebuginfo - Should the class file be compiled with debugging information? true or false, default true.
  • classpath - What class path should I use while compiling generated servlets? By default the classpath is created dynamically based on the current web application.
  • development - Is Jasper used in development mode (will check for JSP modification on every access)? true or false, default true.
  • enablePooling - Determines whether tag handler pooling is enabled. true or false, default true.
  • ieClassId - The class-id value to be sent to Internet Explorer when using <jsp:plugin> tags. Default clsid:8AD9C840-044E-11D1-B3E9-00805F499D93.
  • javaEncoding - Java file encoding to use for generating java source files. Default UTF8.
  • keepgenerated - Should we keep the generated Java source code for each page instead of deleting it? true or false, default true.
  • largefile - Should we store the static content of JSP pages in external data files, to reduce the size of the generated servlets? true or false, default false.
  • logVerbosityLevel - The level of detailed messages to be produced by this servlet. Increasing levels cause the generation of more messages. Valid values are FATAL, ERROR, WARNING, INFORMATION, and DEBUG. Default WARNING.
  • mappedfile - Should we generate static content with one print statement per input line, to ease debugging? true or false, default false.
  • reloading - Should Jasper check for modified JSPs? true or false, default true.
  • scratchdir - What scratch directory should we use when compiling JSP pages? Default is the work directory for the current web application.

Production Configuration

When using Jasper 2 in a production Tomcat server you should consider making the following changes from the default configuration.

  • development - To enable background compilation of JSP pages set this to false.
  • compiler - The internal JVM javac compiler used by Ant has a known memory leak. If you anticipate that JSP pages will get recompiled frequently consider using an external compiler such as jikes.

Using Jikes

If you wish to use Jikes to compile JSP pages:

  • Download and install jikes.
  • Set the init parameter compiler to jikes.
  • Define the property -Dbuild.compiler.emacs=true when starting Tomcat by adding it to your CATALINA_OPTS environment variable. This changes how jikes outputs error messages so that it is compatible with Jasper.
  • If you get an error reporting that jikes can't use UTF8 encoding, try setting the init parameter javaEncoding to ISO-8859-1.


Copyright © 1999-2002, Apache Software Foundation