FileDocCategorySizeDatePackage
EmbeddedServletOptions.javaAPI DocApache Tomcat 6.0.1421946Fri Jul 20 04:20:32 BST 2007org.apache.jasper

EmbeddedServletOptions

public final class EmbeddedServletOptions extends Object implements Options
A class to hold all init parameters specific to the JSP engine.
author
Anil K. Vijendran
author
Hans Bergsten
author
Pierre Delisle

Fields Summary
private org.apache.juli.logging.Log
log
private Properties
settings
private boolean
development
Is Jasper being used in development mode?
public boolean
fork
Should Ant fork its java compiles of JSP pages.
private boolean
keepGenerated
Do you want to keep the generated Java files around?
private boolean
trimSpaces
Should white spaces between directives or actions be trimmed?
private boolean
isPoolingEnabled
Determines whether tag handler pooling is enabled.
private boolean
mappedFile
Do you want support for "mapped" files? This will generate servlet that has a print statement per line of the JSP file. This seems like a really nice feature to have for debugging.
private boolean
sendErrorToClient
Do you want stack traces and such displayed in the client's browser? If this is false, such messages go to the standard error or a log file if the standard error is redirected.
private boolean
classDebugInfo
Do we want to include debugging information in the class file?
private int
checkInterval
Background compile thread check interval in seconds.
private boolean
isSmapSuppressed
Is the generation of SMAP info for JSR45 debuggin suppressed?
private boolean
isSmapDumped
Should SMAP info for JSR45 debugging be dumped to a file?
private boolean
genStringAsCharArray
Are Text strings to be generated as char arrays?
private boolean
errorOnUseBeanInvalidClassAttribute
private File
scratchDir
I want to see my generated servlets. Which directory are they in?
private String
ieClassId
Need to have this as is for versions 4 and 5 of IE. Can be set from the initParams so if it changes in the future all that is needed is to have a jsp initParam of type ieClassId=""
private String
classpath
What classpath should I use while compiling generated servlets?
private String
compiler
Compiler to use.
private String
compilerTargetVM
Compiler target VM.
private String
compilerSourceVM
The compiler source VM.
private String
compilerClassName
The compiler class name.
private org.apache.jasper.compiler.TldLocationsCache
tldLocationsCache
Cache for the TLD locations
private org.apache.jasper.compiler.JspConfig
jspConfig
Jsp config information
private org.apache.jasper.compiler.TagPluginManager
tagPluginManager
TagPluginManager
private String
javaEncoding
Java platform encoding to generate the JSP page servlet.
private int
modificationTestInterval
Modification test interval.
private boolean
xpoweredBy
Is generation of X-Powered-By response header enabled/disabled?
private boolean
displaySourceFragment
Should we include a source fragment in exception messages, which could be displayed to the developer ?
Constructors Summary
public EmbeddedServletOptions(ServletConfig config, ServletContext context)
Create an EmbeddedServletOptions object using data available from ServletConfig and ServletContext.

        
        // JVM version numbers
        try {
            if (Float.parseFloat(System.getProperty("java.specification.version")) > 1.4) {
                compilerSourceVM = compilerTargetVM = "1.5";
            } else {
                compilerSourceVM = compilerTargetVM = "1.4";
            }
        } catch (NumberFormatException e) {
            // Ignore
        }
        
        Enumeration enumeration=config.getInitParameterNames();
        while( enumeration.hasMoreElements() ) {
            String k=(String)enumeration.nextElement();
            String v=config.getInitParameter( k );
            setProperty( k, v);
        }
        
        // quick hack
        String validating=config.getInitParameter( "validating");
        if( "false".equals( validating )) ParserUtils.validating=false;
        
        String keepgen = config.getInitParameter("keepgenerated");
        if (keepgen != null) {
            if (keepgen.equalsIgnoreCase("true")) {
                this.keepGenerated = true;
            } else if (keepgen.equalsIgnoreCase("false")) {
                this.keepGenerated = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.keepgen"));
                }
            }
        }
        
        
        String trimsp = config.getInitParameter("trimSpaces"); 
        if (trimsp != null) {
            if (trimsp.equalsIgnoreCase("true")) {
                trimSpaces = true;
            } else if (trimsp.equalsIgnoreCase("false")) {
                trimSpaces = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.trimspaces"));
                }
            }
        }
        
        this.isPoolingEnabled = true;
        String poolingEnabledParam
        = config.getInitParameter("enablePooling"); 
        if (poolingEnabledParam != null
                && !poolingEnabledParam.equalsIgnoreCase("true")) {
            if (poolingEnabledParam.equalsIgnoreCase("false")) {
                this.isPoolingEnabled = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.enablePooling"));
                }		       	   
            }
        }
        
        String mapFile = config.getInitParameter("mappedfile"); 
        if (mapFile != null) {
            if (mapFile.equalsIgnoreCase("true")) {
                this.mappedFile = true;
            } else if (mapFile.equalsIgnoreCase("false")) {
                this.mappedFile = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.mappedFile"));
                }
            }
        }
        
        String senderr = config.getInitParameter("sendErrToClient");
        if (senderr != null) {
            if (senderr.equalsIgnoreCase("true")) {
                this.sendErrorToClient = true;
            } else if (senderr.equalsIgnoreCase("false")) {
                this.sendErrorToClient = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.sendErrToClient"));
                }
            }
        }
        
        String debugInfo = config.getInitParameter("classdebuginfo");
        if (debugInfo != null) {
            if (debugInfo.equalsIgnoreCase("true")) {
                this.classDebugInfo  = true;
            } else if (debugInfo.equalsIgnoreCase("false")) {
                this.classDebugInfo  = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.classDebugInfo"));
                }
            }
        }
        
        String checkInterval = config.getInitParameter("checkInterval");
        if (checkInterval != null) {
            try {
                this.checkInterval = Integer.parseInt(checkInterval);
            } catch(NumberFormatException ex) {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
                }
            }
        }
        
        String modificationTestInterval = config.getInitParameter("modificationTestInterval");
        if (modificationTestInterval != null) {
            try {
                this.modificationTestInterval = Integer.parseInt(modificationTestInterval);
            } catch(NumberFormatException ex) {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.modificationTestInterval"));
                }
            }
        }
        
        String development = config.getInitParameter("development");
        if (development != null) {
            if (development.equalsIgnoreCase("true")) {
                this.development = true;
            } else if (development.equalsIgnoreCase("false")) {
                this.development = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.development"));
                }
            }
        }
        
        String suppressSmap = config.getInitParameter("suppressSmap");
        if (suppressSmap != null) {
            if (suppressSmap.equalsIgnoreCase("true")) {
                isSmapSuppressed = true;
            } else if (suppressSmap.equalsIgnoreCase("false")) {
                isSmapSuppressed = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.suppressSmap"));
                }
            }
        }
        
        String dumpSmap = config.getInitParameter("dumpSmap");
        if (dumpSmap != null) {
            if (dumpSmap.equalsIgnoreCase("true")) {
                isSmapDumped = true;
            } else if (dumpSmap.equalsIgnoreCase("false")) {
                isSmapDumped = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.dumpSmap"));
                }
            }
        }
        
        String genCharArray = config.getInitParameter("genStrAsCharArray");
        if (genCharArray != null) {
            if (genCharArray.equalsIgnoreCase("true")) {
                genStringAsCharArray = true;
            } else if (genCharArray.equalsIgnoreCase("false")) {
                genStringAsCharArray = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.genchararray"));
                }
            }
        }
        
        String errBeanClass =
            config.getInitParameter("errorOnUseBeanInvalidClassAttribute");
        if (errBeanClass != null) {
            if (errBeanClass.equalsIgnoreCase("true")) {
                errorOnUseBeanInvalidClassAttribute = true;
            } else if (errBeanClass.equalsIgnoreCase("false")) {
                errorOnUseBeanInvalidClassAttribute = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.errBean"));
                }
            }
        }
        
        String ieClassId = config.getInitParameter("ieClassId");
        if (ieClassId != null)
            this.ieClassId = ieClassId;
        
        String classpath = config.getInitParameter("classpath");
        if (classpath != null)
            this.classpath = classpath;
        
        /*
         * scratchdir
         */
        String dir = config.getInitParameter("scratchdir"); 
        if (dir != null) {
            scratchDir = new File(dir);
        } else {
            // First try the Servlet 2.2 javax.servlet.context.tempdir property
            scratchDir = (File) context.getAttribute(Constants.TMP_DIR);
            if (scratchDir == null) {
                // Not running in a Servlet 2.2 container.
                // Try to get the JDK 1.2 java.io.tmpdir property
                dir = System.getProperty("java.io.tmpdir");
                if (dir != null)
                    scratchDir = new File(dir);
            }
        }      
        if (this.scratchDir == null) {
            log.fatal(Localizer.getMessage("jsp.error.no.scratch.dir"));
            return;
        }
        
        if (!(scratchDir.exists() && scratchDir.canRead() &&
                scratchDir.canWrite() && scratchDir.isDirectory()))
            log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir",
                    scratchDir.getAbsolutePath()));
        
        this.compiler = config.getInitParameter("compiler");
        
        String compilerTargetVM = config.getInitParameter("compilerTargetVM");
        if(compilerTargetVM != null) {
            this.compilerTargetVM = compilerTargetVM;
        }
        
        String compilerSourceVM = config.getInitParameter("compilerSourceVM");
        if(compilerSourceVM != null) {
            this.compilerSourceVM = compilerSourceVM;
        }
        
        String javaEncoding = config.getInitParameter("javaEncoding");
        if (javaEncoding != null) {
            this.javaEncoding = javaEncoding;
        }
        
        String compilerClassName = config.getInitParameter("compilerClassName");
        if (compilerClassName != null) {
            this.compilerClassName = compilerClassName;
        }
        
        String fork = config.getInitParameter("fork");
        if (fork != null) {
            if (fork.equalsIgnoreCase("true")) {
                this.fork = true;
            } else if (fork.equalsIgnoreCase("false")) {
                this.fork = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.fork"));
                }
            }
        }
        
        String xpoweredBy = config.getInitParameter("xpoweredBy"); 
        if (xpoweredBy != null) {
            if (xpoweredBy.equalsIgnoreCase("true")) {
                this.xpoweredBy = true;
            } else if (xpoweredBy.equalsIgnoreCase("false")) {
                this.xpoweredBy = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.xpoweredBy"));
                }
            }
        }
        
        String displaySourceFragment = config.getInitParameter("displaySourceFragment"); 
        if (displaySourceFragment != null) {
            if (displaySourceFragment.equalsIgnoreCase("true")) {
                this.displaySourceFragment = true;
            } else if (displaySourceFragment.equalsIgnoreCase("false")) {
                this.displaySourceFragment = false;
            } else {
                if (log.isWarnEnabled()) {
                    log.warn(Localizer.getMessage("jsp.warning.displaySourceFragment"));
                }
            }
        }
        
        // Setup the global Tag Libraries location cache for this
        // web-application.
        tldLocationsCache = new TldLocationsCache(context);
        
        // Setup the jsp config info for this web app.
        jspConfig = new JspConfig(context);
        
        // Create a Tag plugin instance
        tagPluginManager = new TagPluginManager(context);
    
Methods Summary
public booleangenStringAsCharArray()
Are Text strings to be generated as char arrays?

        return this.genStringAsCharArray;
    
public java.util.MapgetCache()

        return null;
    
public intgetCheckInterval()
Background JSP compile thread check intervall

        return checkInterval;
    
public booleangetClassDebugInfo()
Should class files be compiled with debug information?

        return classDebugInfo;
    
public java.lang.StringgetClassPath()
What classpath should I use while compiling the servlets generated from JSP files?

        return classpath;
    
public java.lang.StringgetCompiler()
Compiler to use.

        return compiler;
    
public java.lang.StringgetCompilerClassName()
Java compiler class to use.

        return compilerClassName;
    
public java.lang.StringgetCompilerSourceVM()

see
Options#getCompilerSourceVM

        return compilerSourceVM;
    
public java.lang.StringgetCompilerTargetVM()

see
Options#getCompilerTargetVM

        return compilerTargetVM;
    
public booleangetDevelopment()
Is Jasper being used in development mode?

        return development;
    
public booleangetDisplaySourceFragment()
Should we include a source fragment in exception messages, which could be displayed to the developer ?

        return displaySourceFragment;
    
public booleangetErrorOnUseBeanInvalidClassAttribute()

        return errorOnUseBeanInvalidClassAttribute;
    
public booleangetFork()

        return fork;
    
public java.lang.StringgetIeClassId()
Class ID for use in the plugin tag when the browser is IE.

        return ieClassId;
    
public java.lang.StringgetJavaEncoding()

        return javaEncoding;
    
public org.apache.jasper.compiler.JspConfiggetJspConfig()

        return jspConfig;
    
public booleangetKeepGenerated()
Are we keeping generated code around?

        return keepGenerated;
    
public booleangetMappedFile()
Are we supporting HTML mapped servlets?

        return mappedFile;
    
public intgetModificationTestInterval()
Modification test interval.

        return modificationTestInterval;
    
public java.lang.StringgetProperty(java.lang.String name)


    
         
        return settings.getProperty( name );
    
public java.io.FilegetScratchDir()
What is my scratch dir?

        return scratchDir;
    
public booleangetSendErrorToClient()
Should errors be sent to client or thrown into stderr?

        return sendErrorToClient;
    
public org.apache.jasper.compiler.TagPluginManagergetTagPluginManager()

        return tagPluginManager;
    
public org.apache.jasper.compiler.TldLocationsCachegetTldLocationsCache()

        return tldLocationsCache;
    
public booleangetTrimSpaces()
Should white spaces between directives or actions be trimmed?

        return trimSpaces;
    
public booleanisCaching()

        return false;
    
public booleanisPoolingEnabled()

        return isPoolingEnabled;
    
public booleanisSmapDumped()
Should SMAP info for JSR45 debugging be dumped to a file?

        return isSmapDumped;
    
public booleanisSmapSuppressed()
Is the generation of SMAP info for JSR45 debuggin suppressed?

        return isSmapSuppressed;
    
public booleanisXpoweredBy()
Is generation of X-Powered-By response header enabled/disabled?

        return xpoweredBy;
    
public voidsetErrorOnUseBeanInvalidClassAttribute(boolean b)

        errorOnUseBeanInvalidClassAttribute = b;
    
public voidsetProperty(java.lang.String name, java.lang.String value)

        if (name != null && value != null){ 
            settings.setProperty( name, value );
        }
    
public voidsetTldLocationsCache(org.apache.jasper.compiler.TldLocationsCache tldC)

        tldLocationsCache = tldC;