> > Given that the default web.xml is not being read, how do you enable Jikes as
> > the JspCompiler?  That setting used to be in web.xml.  What's the syntax to
> > specify it in server.xml, or did we lose this functionality for Tomcat 3.2?
> > (If so, could it be put back, or define a syntax in server.xml for it?).
> 
> I'll try to write a small interceptor that sets the compiler and other
> options for jasper ( probably next week it'll be ready ). ( that will not
> require a new release of tomcat - you just install the interceptor in the
> classpath and add it to tomcat.jar ).

Ok, I don't think it'll be ready next week - you can use it today, it took
10 minutes to write and test :-)

You can set all the options that jasper knows - compile the interceptor (
you need tomcat jars in CLASSPATH ), add it to CLASSPATH, and then 
add in your server.xml ( after WebXmlReader ):

        <ContextInterceptor
            className="tc3.JasperOptions"
            keepGenerated="true"
            jspCompilerPlugin="org.apache.jasper.compiler.JikesJavaCompiler"
        />
 
( run javadoc and read all other options you can set ).
It should work with any tomcat 3.2 - in 3.3 there is already one 
( JspInterceptor ) that does a much better integration ( and is faster
than the servlet used in 3.2 ).

Costin
/*
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights 
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:  
 *       "This product includes software developed by the 
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written 
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */ 


package tc3;

import org.apache.tomcat.core.*;
import org.apache.tomcat.core.Constants;
import org.apache.tomcat.util.*;
import java.io.*;
import java.net.*;
import java.util.*;

/**
 * To set Jasper options. Needs to be installed just after WebXmlReader.
 * 
 *
 * Supports all of the  existing options in EmbededServletOptions.
 *
 * @author [EMAIL PROTECTED]
 */
public class JasperOptions extends BaseInterceptor {
    
    public JasperOptions() {
    }

    Hashtable args=new Hashtable();
    
    /**
     * Are we keeping generated code around?
     */
    public void setKeepGenerated( String s ) {
        args.put( "keepgenerated", s );
    }

    /**
     * Are we supporting large files?
     */
    public void setLargeFile( String s ) {
        args.put( "largefile", s );
    }

    /**
     * Are we supporting HTML mapped servlets?
     */
    public void setMappedFile( String s ) {
        args.put( "mappedfile", s );
    }

    /**
     * Should errors be sent to client or thrown into stderr?
     */
    public void setSendErrToClient( String s ) {
        args.put( "sendErrToClient", s );
    }

    /**
     * Class ID for use in the plugin tag when the browser is IE. 
     */
    public void setIEClassId( String s ) {
        args.put( "ieClassId", s );
    }

    /**
     * What classpath should I use while compiling the servlets
     * generated from JSP files?
     */
    public void setClassPath( String s ) {
        args.put( "classpath", s );
    }

    /**
     * What is my scratch dir?
     */
    public void setScratchdir( String s ) {
        args.put( "scratchdir", s );
    }

    /**
     * Path of the compiler to use for compiling JSP pages.
     */
    public void setJspCompilerPath( String s ) {
        args.put( "jspCompilerPath", s );
    }

    /**
     * What compiler plugin should I use to compile the servlets
     * generated from JSP files?
     */
    public void setJspCompilerPlugin( String s ) {
        args.put( "jspCompilerPlugin", s );
    }

    public void contextInit(Context ctx) {
        ServletWrapper jasper=ctx.getServletByName( "jsp" );
        if ( debug>10) log( "Got jasper servlet " + jasper );

        Enumeration enum=args.keys();
        while( enum.hasMoreElements() ) {
            String s=(String)enum.nextElement();
            String v=(String)args.get(s);
            if( debug>0 ) log( "Setting " + s + "=" + v );
            jasper.addInitParam(s, v );
        }
    }
}

Reply via email to