org.apache.jasper_5.5.17.v201101211617

16:41:07.465 INFO  jd.cli.Main - Decompiling org.apache.jasper_5.5.17.v201101211617.jar
package org.apache.jasper;

public class Constants
{
  public static final String JSP_SERVLET_BASE = "org.apache.jasper.runtime.HttpJspBase";
  public static final String SERVICE_METHOD_NAME = "_jspService";
  public static final String SERVLET_CONTENT_TYPE = "text/html";
  public static final String[] STANDARD_IMPORTS = { "javax.servlet.*", "javax.servlet.http.*", "javax.servlet.jsp.*" };
  public static final String SERVLET_CLASSPATH = "org.apache.catalina.jsp_classpath";
  public static final String JSP_FILE = "org.apache.catalina.jsp_file";
  public static final String SERVLET_CLASS_LOADER = "org.apache.catalina.classloader";
  public static final int K = 1024;
  public static final int DEFAULT_BUFFER_SIZE = 8192;
  public static final int DEFAULT_TAG_BUFFER_SIZE = 512;
  public static final int MAX_POOL_SIZE = 5;
  public static final String PRECOMPILE = "jsp_precompile";
  public static final String JSP_PACKAGE_NAME = "org.apache.jsp";
  public static final String TAG_FILE_PACKAGE_NAME = "org.apache.jsp.tag";
  public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
  public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
  public static final String TMP_DIR = "javax.servlet.context.tempdir";
  public static final String FORWARD_SEEN = "javax.servlet.forward.seen";
  public static final String ALT_DD_ATTR = "org.apache.catalina.deploy.alt_dd";
  public static final String TAGLIB_DTD_PUBLIC_ID_11 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
  public static final String TAGLIB_DTD_RESOURCE_PATH_11 = "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
  public static final String TAGLIB_DTD_PUBLIC_ID_12 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
  public static final String TAGLIB_DTD_RESOURCE_PATH_12 = "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
  public static final String WEBAPP_DTD_PUBLIC_ID_22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
  public static final String WEBAPP_DTD_RESOURCE_PATH_22 = "/javax/servlet/resources/web-app_2_2.dtd";
  public static final String WEBAPP_DTD_PUBLIC_ID_23 = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
  public static final String WEBAPP_DTD_RESOURCE_PATH_23 = "/javax/servlet/resources/web-app_2_3.dtd";
  public static final String[] CACHED_DTD_PUBLIC_IDS = { "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN", "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN", "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" };
  public static final String[] CACHED_DTD_RESOURCE_PATHS = { "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd", "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd", "/javax/servlet/resources/web-app_2_2.dtd", "/javax/servlet/resources/web-app_2_3.dtd" };
  public static final String NS_PLUGIN_URL = "http://java.sun.com/products/plugin/";
  public static final String IE_PLUGIN_URL = "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
  public static final String TEMP_VARIABLE_NAME_PREFIX = "_jspx_temp";
  public static final char ESC = '\033';
  public static final String ESCStr = "'\\u001b'";
}

/* Location:
 * Qualified Name:     org.apache.jasper.Constants
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.jasper;

import java.io.File;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jasper.compiler.JspConfig;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.compiler.TagPluginManager;
import org.apache.jasper.compiler.TldLocationsCache;

public final class EmbeddedServletOptions
  implements Options
{
  private Log log = LogFactory.getLog(EmbeddedServletOptions.class);
  private Properties settings = new Properties();
  private boolean development = true;
  public boolean fork = true;
  private boolean keepGenerated = true;
  private boolean trimSpaces = false;
  private boolean isPoolingEnabled = true;
  private boolean mappedFile = true;
  private boolean sendErrorToClient = false;
  private boolean classDebugInfo = true;
  private int checkInterval = 0;
  private boolean isSmapSuppressed = false;
  private boolean isSmapDumped = false;
  private boolean genStringAsCharArray = false;
  private boolean errorOnUseBeanInvalidClassAttribute = true;
  private File scratchDir;
  private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
  private String classpath = null;
  private String compiler = null;
  private String compilerTargetVM = "1.5";
  private String compilerSourceVM = "1.5";
  private TldLocationsCache tldLocationsCache = null;
  private JspConfig jspConfig = null;
  private TagPluginManager tagPluginManager = null;
  private String javaEncoding = "UTF8";
  private int modificationTestInterval = 4;
  private boolean xpoweredBy;
  
  public String getProperty(String name)
  {
    return settings.getProperty(name);
  }
  
  public void setProperty(String name, String value)
  {
    if ((name != null) && (value != null)) {
      settings.setProperty(name, value);
    }
  }
  
  public boolean getKeepGenerated()
  {
    return keepGenerated;
  }
  
  public boolean getTrimSpaces()
  {
    return trimSpaces;
  }
  
  public boolean isPoolingEnabled()
  {
    return isPoolingEnabled;
  }
  
  public boolean getMappedFile()
  {
    return mappedFile;
  }
  
  public boolean getSendErrorToClient()
  {
    return sendErrorToClient;
  }
  
  public boolean getClassDebugInfo()
  {
    return classDebugInfo;
  }
  
  public int getCheckInterval()
  {
    return checkInterval;
  }
  
  public int getModificationTestInterval()
  {
    return modificationTestInterval;
  }
  
  public boolean getDevelopment()
  {
    return development;
  }
  
  public boolean isSmapSuppressed()
  {
    return isSmapSuppressed;
  }
  
  public boolean isSmapDumped()
  {
    return isSmapDumped;
  }
  
  public boolean genStringAsCharArray()
  {
    return genStringAsCharArray;
  }
  
  public String getIeClassId()
  {
    return ieClassId;
  }
  
  public File getScratchDir()
  {
    return scratchDir;
  }
  
  public String getClassPath()
  {
    return classpath;
  }
  
  public boolean isXpoweredBy()
  {
    return xpoweredBy;
  }
  
  public String getCompiler()
  {
    return compiler;
  }
  
  public String getCompilerTargetVM()
  {
    return compilerTargetVM;
  }
  
  public String getCompilerSourceVM()
  {
    return compilerSourceVM;
  }
  
  public boolean getErrorOnUseBeanInvalidClassAttribute()
  {
    return errorOnUseBeanInvalidClassAttribute;
  }
  
  public void setErrorOnUseBeanInvalidClassAttribute(boolean b)
  {
    errorOnUseBeanInvalidClassAttribute = b;
  }
  
  public TldLocationsCache getTldLocationsCache()
  {
    return tldLocationsCache;
  }
  
  public void setTldLocationsCache(TldLocationsCache tldC)
  {
    tldLocationsCache = tldC;
  }
  
  public String getJavaEncoding()
  {
    return javaEncoding;
  }
  
  public boolean getFork()
  {
    return fork;
  }
  
  public JspConfig getJspConfig()
  {
    return jspConfig;
  }
  
  public TagPluginManager getTagPluginManager()
  {
    return tagPluginManager;
  }
  
  public boolean isCaching()
  {
    return false;
  }
  
  public Map getCache()
  {
    return null;
  }
  
  public EmbeddedServletOptions(ServletConfig config, ServletContext context)
  {
    try
    {
      if (Float.parseFloat(System.getProperty("java.specification.version")) > 1.4D) {
        this.compilerSourceVM = (this.compilerTargetVM = "1.5");
      } else {
        this.compilerSourceVM = (this.compilerTargetVM = "1.4");
      }
    }
    catch (NumberFormatException e) {}
    Enumeration enumeration = config.getInitParameterNames();
    while (enumeration.hasMoreElements())
    {
      String k = (String)enumeration.nextElement();
      String v = config.getInitParameter(k);
      setProperty(k, v);
    }
    String validating = config.getInitParameter("validating");
    if ("false".equals(validating)) {
      org.apache.jasper.xmlparser.ParserUtils.validating = false;
    }
    String keepgen = config.getInitParameter("keepgenerated");
    if (keepgen != null) {
      if (keepgen.equalsIgnoreCase("true")) {
        keepGenerated = true;
      } else if (keepgen.equalsIgnoreCase("false")) {
        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"));
      }
    }
    isPoolingEnabled = true;
    String poolingEnabledParam = config.getInitParameter("enablePooling");
    if ((poolingEnabledParam != null) && (!poolingEnabledParam.equalsIgnoreCase("true"))) {
      if (poolingEnabledParam.equalsIgnoreCase("false")) {
        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")) {
        mappedFile = true;
      } else if (mapFile.equalsIgnoreCase("false")) {
        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")) {
        sendErrorToClient = true;
      } else if (senderr.equalsIgnoreCase("false")) {
        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")) {
        classDebugInfo = true;
      } else if (debugInfo.equalsIgnoreCase("false")) {
        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);
        if (this.checkInterval == 0)
        {
          this.checkInterval = 300;
          if (log.isWarnEnabled()) {
            log.warn(Localizer.getMessage("jsp.warning.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;
    }
    String dir = config.getInitParameter("scratchdir");
    if (dir != null)
    {
      scratchDir = new File(dir);
    }
    else
    {
      scratchDir = ((File)context.getAttribute("javax.servlet.context.tempdir"));
      if (scratchDir == null)
      {
        dir = System.getProperty("java.io.tmpdir");
        if (dir != null) {
          scratchDir = new File(dir);
        }
      }
    }
    if (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()));
    }
    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 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"));
      }
    }
    tldLocationsCache = new TldLocationsCache(context);
    
    jspConfig = new JspConfig(context);
    
    tagPluginManager = new TagPluginManager(context);
  }
}

/* Location:
 * Qualified Name:     org.apache.jasper.EmbeddedServletOptions
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.jasper;

import javax.servlet.ServletException;

public class JasperException
  extends ServletException
{
  public JasperException(String reason)
  {
    super(reason);
  }
  
  public JasperException(String reason, Throwable exception)
  {
    super(reason, exception);
  }
  
  public JasperException(Throwable exception)
  {
    super(exception);
  }
}

/* Location:
 * Qualified Name:     org.apache.jasper.JasperException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.jasper;

import java.io.BufferedReader;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jasper.compiler.Compiler;
import org.apache.jasper.compiler.JspConfig;
import org.apache.jasper.compiler.JspRuntimeContext;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.compiler.TagPluginManager;
import org.apache.jasper.compiler.TldLocationsCache;
import org.apache.jasper.servlet.JspCServletContext;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;

public class JspC
  implements Options
{
  public static final String DEFAULT_IE_CLASS_ID = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
  private static Log log = LogFactory.getLog(JspC.class);
  private static final String SWITCH_VERBOSE = "-v";
  private static final String SWITCH_HELP = "-help";
  private static final String SWITCH_QUIET = "-q";
  private static final String SWITCH_OUTPUT_DIR = "-d";
  private static final String SWITCH_IE_CLASS_ID = "-ieplugin";
  private static final String SWITCH_PACKAGE_NAME = "-p";
  private static final String SWITCH_CACHE = "-cache";
  private static final String SWITCH_CLASS_NAME = "-c";
  private static final String SWITCH_FULL_STOP = "--";
  private static final String SWITCH_COMPILE = "-compile";
  private static final String SWITCH_SOURCE = "-source";
  private static final String SWITCH_TARGET = "-target";
  private static final String SWITCH_URI_BASE = "-uribase";
  private static final String SWITCH_URI_ROOT = "-uriroot";
  private static final String SWITCH_FILE_WEBAPP = "-webapp";
  private static final String SWITCH_WEBAPP_INC = "-webinc";
  private static final String SWITCH_WEBAPP_XML = "-webxml";
  private static final String SWITCH_MAPPED = "-mapped";
  private static final String SWITCH_XPOWERED_BY = "-xpoweredBy";
  private static final String SWITCH_TRIM_SPACES = "-trimSpaces";
  private static final String SWITCH_CLASSPATH = "-classpath";
  private static final String SWITCH_DIE = "-die";
  private static final String SWITCH_POOLING = "-poolingEnabled";
  private static final String SWITCH_ENCODING = "-javaEncoding";
  private static final String SWITCH_SMAP = "-smap";
  private static final String SWITCH_DUMP_SMAP = "-dumpsmap";
  private static final String SHOW_SUCCESS = "-s";
  private static final String LIST_ERRORS = "-l";
  private static final int NO_WEBXML = 0;
  private static final int INC_WEBXML = 10;
  private static final int ALL_WEBXML = 20;
  private static final int DEFAULT_DIE_LEVEL = 1;
  private static final int NO_DIE_LEVEL = 0;
  private static final String[] insertBefore = { "</web-app>", "<servlet-mapping>", "<session-config>", "<mime-mapping>", "<welcome-file-list>", "<error-page>", "<taglib>", "<resource-env-ref>", "<resource-ref>", "<security-constraint>", "<login-config>", "<security-role>", "<env-entry>", "<ejb-ref>", "<ejb-local-ref>" };
  private static int die;
  private String classPath = null;
  private URLClassLoader loader = null;
  private boolean trimSpaces = false;
  private boolean genStringAsCharArray = false;
  private boolean xpoweredBy;
  private boolean mappedFile = false;
  private boolean poolingEnabled = true;
  private File scratchDir;
  private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
  private String targetPackage;
  private String targetClassName;
  private String uriBase;
  private String uriRoot;
  private Project project;
  private int dieLevel;
  private boolean helpNeeded = false;
  private boolean compile = false;
  private boolean smapSuppressed = true;
  private boolean smapDumped = false;
  private boolean caching = true;
  private Map cache = new HashMap();
  private String compiler = null;
  private String compilerTargetVM = "1.4";
  private String compilerSourceVM = "1.4";
  private boolean classDebugInfo = true;
  private boolean failOnError = true;
  private List extensions;
  private List pages = new Vector();
  private boolean errorOnUseBeanInvalidClassAttribute = true;
  private String javaEncoding = "UTF-8";
  private String webxmlFile;
  private int webxmlLevel;
  private boolean addWebXmlMappings = false;
  private Writer mapout;
  private CharArrayWriter servletout;
  private CharArrayWriter mappingout;
  private JspCServletContext context;
  private JspRuntimeContext rctxt;
  private TldLocationsCache tldLocationsCache = null;
  private JspConfig jspConfig = null;
  private TagPluginManager tagPluginManager = null;
  private boolean verbose = false;
  private boolean listErrors = false;
  private boolean showSuccess = false;
  private int argPos;
  private boolean fullstop = false;
  private String[] args;
  
  public static void main(String[] arg)
  {
    if (arg.length == 0) {
      System.out.println(Localizer.getMessage("jspc.usage"));
    } else {
      try
      {
        JspC jspc = new JspC();
        jspc.setArgs(arg);
        if (helpNeeded) {
          System.out.println(Localizer.getMessage("jspc.usage"));
        } else {
          jspc.execute();
        }
      }
      catch (JasperException je)
      {
        System.err.println(je);
        if (die != 0) {
          System.exit(die);
        }
      }
    }
  }
  
  public void setArgs(String[] arg)
    throws JasperException
  {
    args = arg;
    
    dieLevel = 0;
    die = dieLevel;
    String tok;
    while ((tok = nextArg()) != null) {
      if (tok.equals("-v"))
      {
        verbose = true;
        showSuccess = true;
        listErrors = true;
      }
      else if (tok.equals("-d"))
      {
        tok = nextArg();
        setOutputDir(tok);
      }
      else if (tok.equals("-p"))
      {
        targetPackage = nextArg();
      }
      else if (tok.equals("-compile"))
      {
        compile = true;
      }
      else if (tok.equals("-c"))
      {
        targetClassName = nextArg();
      }
      else if (tok.equals("-uribase"))
      {
        uriBase = nextArg();
      }
      else if (tok.equals("-uriroot"))
      {
        setUriroot(nextArg());
      }
      else if (tok.equals("-webapp"))
      {
        setUriroot(nextArg());
      }
      else if (tok.equals("-s"))
      {
        showSuccess = true;
      }
      else if (tok.equals("-l"))
      {
        listErrors = true;
      }
      else if (tok.equals("-webinc"))
      {
        webxmlFile = nextArg();
        if (webxmlFile != null) {
          webxmlLevel = 10;
        }
      }
      else if (tok.equals("-webxml"))
      {
        webxmlFile = nextArg();
        if (webxmlFile != null) {
          webxmlLevel = 20;
        }
      }
      else if (tok.equals("-mapped"))
      {
        mappedFile = true;
      }
      else if (tok.equals("-xpoweredBy"))
      {
        xpoweredBy = true;
      }
      else if (tok.equals("-trimSpaces"))
      {
        setTrimSpaces(true);
      }
      else if (tok.equals("-cache"))
      {
        tok = nextArg();
        if ("false".equals(tok)) {
          caching = false;
        } else {
          caching = true;
        }
      }
      else if (tok.equals("-classpath"))
      {
        setClassPath(nextArg());
      }
      else if (tok.startsWith("-die"))
      {
        try
        {
          dieLevel = Integer.parseInt(tok.substring("-die".length()));
        }
        catch (NumberFormatException nfe)
        {
          dieLevel = 1;
        }
        die = dieLevel;
      }
      else if (tok.equals("-help"))
      {
        helpNeeded = true;
      }
      else if (tok.equals("-poolingEnabled"))
      {
        tok = nextArg();
        if ("false".equals(tok)) {
          poolingEnabled = false;
        } else {
          poolingEnabled = true;
        }
      }
      else if (tok.equals("-javaEncoding"))
      {
        setJavaEncoding(nextArg());
      }
      else if (tok.equals("-source"))
      {
        setCompilerSourceVM(nextArg());
      }
      else if (tok.equals("-target"))
      {
        setCompilerTargetVM(nextArg());
      }
      else if (tok.equals("-smap"))
      {
        smapSuppressed = false;
      }
      else if (tok.equals("-dumpsmap"))
      {
        smapDumped = true;
      }
      else
      {
        if (tok.startsWith("-")) {
          throw new JasperException("Unrecognized option: " + tok + ".  Use -help for help.");
        }
        if (!fullstop) {
          argPos -= 1;
        }
      }
    }
    for (;;)
    {
      String file = nextFile();
      if (file == null) {
        break;
      }
      pages.add(file);
    }
  }
  
  public boolean getKeepGenerated()
  {
    return true;
  }
  
  public boolean getTrimSpaces()
  {
    return trimSpaces;
  }
  
  public void setTrimSpaces(boolean ts)
  {
    trimSpaces = ts;
  }
  
  public boolean isPoolingEnabled()
  {
    return poolingEnabled;
  }
  
  public void setPoolingEnabled(boolean poolingEnabled)
  {
    this.poolingEnabled = poolingEnabled;
  }
  
  public boolean isXpoweredBy()
  {
    return xpoweredBy;
  }
  
  public void setXpoweredBy(boolean xpoweredBy)
  {
    this.xpoweredBy = xpoweredBy;
  }
  
  public boolean getErrorOnUseBeanInvalidClassAttribute()
  {
    return errorOnUseBeanInvalidClassAttribute;
  }
  
  public void setErrorOnUseBeanInvalidClassAttribute(boolean b)
  {
    errorOnUseBeanInvalidClassAttribute = b;
  }
  
  public int getTagPoolSize()
  {
    return 5;
  }
  
  public boolean getMappedFile()
  {
    return mappedFile;
  }
  
  public Object getProtectionDomain()
  {
    return null;
  }
  
  public boolean getSendErrorToClient()
  {
    return true;
  }
  
  public void setClassDebugInfo(boolean b)
  {
    classDebugInfo = b;
  }
  
  public boolean getClassDebugInfo()
  {
    return classDebugInfo;
  }
  
  public boolean isCaching()
  {
    return caching;
  }
  
  public void setCaching(boolean caching)
  {
    this.caching = caching;
  }
  
  public Map getCache()
  {
    return cache;
  }
  
  public int getCheckInterval()
  {
    return 0;
  }
  
  public int getModificationTestInterval()
  {
    return 0;
  }
  
  public boolean getDevelopment()
  {
    return false;
  }
  
  public boolean isSmapSuppressed()
  {
    return smapSuppressed;
  }
  
  public void setSmapSuppressed(boolean smapSuppressed)
  {
    this.smapSuppressed = smapSuppressed;
  }
  
  public boolean isSmapDumped()
  {
    return smapDumped;
  }
  
  public void setSmapDumped(boolean smapDumped)
  {
    this.smapDumped = smapDumped;
  }
  
  public void setGenStringAsCharArray(boolean genStringAsCharArray)
  {
    this.genStringAsCharArray = genStringAsCharArray;
  }
  
  public boolean genStringAsCharArray()
  {
    return genStringAsCharArray;
  }
  
  public void setIeClassId(String ieClassId)
  {
    this.ieClassId = ieClassId;
  }
  
  public String getIeClassId()
  {
    return ieClassId;
  }
  
  public File getScratchDir()
  {
    return scratchDir;
  }
  
  public Class getJspCompilerPlugin()
  {
    return null;
  }
  
  public String getJspCompilerPath()
  {
    return null;
  }
  
  public String getCompiler()
  {
    return compiler;
  }
  
  public void setCompiler(String c)
  {
    compiler = c;
  }
  
  public String getCompilerTargetVM()
  {
    return compilerTargetVM;
  }
  
  public void setCompilerTargetVM(String vm)
  {
    compilerTargetVM = vm;
  }
  
  public String getCompilerSourceVM()
  {
    return compilerSourceVM;
  }
  
  public void setCompilerSourceVM(String vm)
  {
    compilerSourceVM = vm;
  }
  
  public TldLocationsCache getTldLocationsCache()
  {
    return tldLocationsCache;
  }
  
  public String getJavaEncoding()
  {
    return javaEncoding;
  }
  
  public void setJavaEncoding(String encodingName)
  {
    javaEncoding = encodingName;
  }
  
  public boolean getFork()
  {
    return false;
  }
  
  public String getClassPath()
  {
    if (classPath != null) {
      return classPath;
    }
    return System.getProperty("java.class.path");
  }
  
  public void setClassPath(String s)
  {
    classPath = s;
  }
  
  public List getExtensions()
  {
    return extensions;
  }
  
  protected void addExtension(String extension)
  {
    if (extension != null)
    {
      if (extensions == null) {
        extensions = new Vector();
      }
      extensions.add(extension);
    }
  }
  
  public void setProject(Project theProject)
  {
    project = theProject;
  }
  
  public Project getProject()
  {
    return project;
  }
  
  public void setUriroot(String s)
  {
    if (s == null)
    {
      uriRoot = s;
      return;
    }
    try
    {
      uriRoot = resolveFile(s).getCanonicalPath();
    }
    catch (Exception ex)
    {
      uriRoot = s;
    }
  }
  
  public void setJspFiles(String jspFiles)
  {
    if (jspFiles == null) {
      return;
    }
    StringTokenizer tok = new StringTokenizer(jspFiles, ",");
    while (tok.hasMoreTokens()) {
      pages.add(tok.nextToken());
    }
  }
  
  public void setCompile(boolean b)
  {
    compile = b;
  }
  
  public void setVerbose(int level)
  {
    if (level > 0)
    {
      verbose = true;
      showSuccess = true;
      listErrors = true;
    }
  }
  
  public void setValidateXml(boolean b)
  {
    org.apache.jasper.xmlparser.ParserUtils.validating = b;
  }
  
  public void setListErrors(boolean b)
  {
    listErrors = b;
  }
  
  public void setOutputDir(String s)
  {
    if (s != null) {
      scratchDir = resolveFile(s).getAbsoluteFile();
    } else {
      scratchDir = null;
    }
  }
  
  public void setPackage(String p)
  {
    targetPackage = p;
  }
  
  public void setClassName(String p)
  {
    targetClassName = p;
  }
  
  public void setWebXmlFragment(String s)
  {
    webxmlFile = resolveFile(s).getAbsolutePath();
    webxmlLevel = 10;
  }
  
  public void setWebXml(String s)
  {
    webxmlFile = resolveFile(s).getAbsolutePath();
    webxmlLevel = 20;
  }
  
  public void setAddWebXmlMappings(boolean b)
  {
    addWebXmlMappings = b;
  }
  
  public void setFailOnError(boolean b)
  {
    failOnError = b;
  }
  
  public boolean getFailOnError()
  {
    return failOnError;
  }
  
  public JspConfig getJspConfig()
  {
    return jspConfig;
  }
  
  public TagPluginManager getTagPluginManager()
  {
    return tagPluginManager;
  }
  
  public void generateWebMapping(String file, JspCompilationContext clctxt)
    throws IOException
  {
    String className = clctxt.getServletClassName();
    String packageName = clctxt.getServletPackageName();
    String thisServletName;
    String thisServletName;
    if ("".equals(packageName)) {
      thisServletName = className;
    } else {
      thisServletName = packageName + '.' + className;
    }
    if (servletout != null)
    {
      servletout.write("\n    <servlet>\n        <servlet-name>");
      servletout.write(thisServletName);
      servletout.write("</servlet-name>\n        <servlet-class>");
      servletout.write(thisServletName);
      servletout.write("</servlet-class>\n    </servlet>\n");
    }
    if (mappingout != null)
    {
      mappingout.write("\n    <servlet-mapping>\n        <servlet-name>");
      mappingout.write(thisServletName);
      mappingout.write("</servlet-name>\n        <url-pattern>");
      mappingout.write(file.replace('\\', '/'));
      mappingout.write("</url-pattern>\n    </servlet-mapping>\n");
    }
  }
  
  protected void mergeIntoWebXml()
    throws IOException
  {
    File webappBase = new File(uriRoot);
    File webXml = new File(webappBase, "WEB-INF/web.xml");
    File webXml2 = new File(webappBase, "WEB-INF/web2.xml");
    String insertStartMarker = Localizer.getMessage("jspc.webinc.insertStart");
    
    String insertEndMarker = Localizer.getMessage("jspc.webinc.insertEnd");
    
    BufferedReader reader = new BufferedReader(new FileReader(webXml));
    BufferedReader fragmentReader = new BufferedReader(new FileReader(webxmlFile));
    
    PrintWriter writer = new PrintWriter(new FileWriter(webXml2));
    
    int pos = -1;
    String line = null;
    for (;;)
    {
      line = reader.readLine();
      if (line == null) {
        break;
      }
      if (line.indexOf(insertStartMarker) >= 0)
      {
        do
        {
          line = reader.readLine();
          if (line == null) {
            return;
          }
        } while (line.indexOf(insertEndMarker) < 0);
        line = reader.readLine();
        line = reader.readLine();
        if (line == null) {
          return;
        }
      }
      for (int i = 0; i < insertBefore.length; i++)
      {
        pos = line.indexOf(insertBefore[i]);
        if (pos >= 0) {
          break;
        }
      }
      if (pos >= 0)
      {
        writer.print(line.substring(0, pos));
        break;
      }
      writer.println(line);
    }
    writer.println(insertStartMarker);
    for (;;)
    {
      String line2 = fragmentReader.readLine();
      if (line2 == null)
      {
        writer.println();
        break;
      }
      writer.println(line2);
    }
    writer.println(insertEndMarker);
    writer.println();
    for (int i = 0; i < pos; i++) {
      writer.print(" ");
    }
    writer.println(line.substring(pos));
    for (;;)
    {
      line = reader.readLine();
      if (line == null) {
        break;
      }
      writer.println(line);
    }
    writer.close();
    
    reader.close();
    fragmentReader.close();
    
    FileInputStream fis = new FileInputStream(webXml2);
    FileOutputStream fos = new FileOutputStream(webXml);
    
    byte[] buf = new byte['?'];
    for (;;)
    {
      int n = fis.read(buf);
      if (n < 0) {
        break;
      }
      fos.write(buf, 0, n);
    }
    fis.close();
    fos.close();
    
    webXml2.delete();
    new File(webxmlFile).delete();
  }
  
  private void processFile(String file)
    throws JasperException
  {
    ClassLoader originalClassLoader = null;
    try
    {
      if (scratchDir == null)
      {
        String temp = System.getProperty("java.io.tmpdir");
        if (temp == null) {
          temp = "";
        }
        scratchDir = new File(new File(temp).getAbsolutePath());
      }
      String jspUri = file.replace('\\', '/');
      JspCompilationContext clctxt = new JspCompilationContext(jspUri, false, this, context, null, rctxt);
      if ((targetClassName != null) && (targetClassName.length() > 0))
      {
        clctxt.setServletClassName(targetClassName);
        targetClassName = null;
      }
      if (targetPackage != null) {
        clctxt.setServletPackageName(targetPackage);
      }
      originalClassLoader = Thread.currentThread().getContextClassLoader();
      if (loader == null) {
        initClassLoader(clctxt);
      }
      Thread.currentThread().setContextClassLoader(loader);
      
      clctxt.setClassLoader(loader);
      clctxt.setClassPath(classPath);
      
      Compiler clc = clctxt.createCompiler();
      if (clc.isOutDated(compile)) {
        clc.compile(compile, true);
      }
      generateWebMapping(file, clctxt);
      if (showSuccess) {
        log.info("Built File: " + file);
      }
    }
    catch (JasperException je)
    {
      Throwable rootCause = je;
      while (((rootCause instanceof JasperException)) && (((JasperException)rootCause).getRootCause() != null)) {
        rootCause = ((JasperException)rootCause).getRootCause();
      }
      if (rootCause != je) {
        log.error(Localizer.getMessage("jspc.error.generalException", file), rootCause);
      }
      if (getFailOnError()) {
        throw je;
      }
      log.error(je.getMessage());
    }
    catch (Exception e)
    {
      if (((e instanceof FileNotFoundException)) && (log.isWarnEnabled())) {
        log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist", e.getMessage()));
      }
      throw new JasperException(e);
    }
    finally
    {
      if (originalClassLoader != null) {
        Thread.currentThread().setContextClassLoader(originalClassLoader);
      }
    }
  }
  
  public void scanFiles(File base)
    throws JasperException
  {
    Stack dirs = new Stack();
    dirs.push(base);
    if ((getExtensions() == null) || (getExtensions().size() < 2))
    {
      addExtension("jsp");
      addExtension("jspx");
    }
    for (; !dirs.isEmpty(); goto 97)
    {
      String s = dirs.pop().toString();
      File f = new File(s);
      if ((f.exists()) && (f.isDirectory()))
      {
        String[] files = f.list();
        
        int i = 0;
        if ((files != null) && (i < files.length))
        {
          File f2 = new File(s, files[i]);
          if (f2.isDirectory())
          {
            dirs.push(f2.getPath());
          }
          else
          {
            String path = f2.getPath();
            String uri = path.substring(uriRoot.length());
            String ext = files[i].substring(files[i].lastIndexOf('.') + 1);
            if ((getExtensions().contains(ext)) || (jspConfig.isJspPage(uri))) {
              pages.add(path);
            }
          }
          i++;
        }
      }
    }
  }
  
  public void execute()
    throws JasperException
  {
    if (log.isDebugEnabled()) {
      log.debug("execute() starting for " + pages.size() + " pages.");
    }
    try
    {
      if (uriRoot == null)
      {
        if (pages.size() == 0) {
          throw new JasperException(Localizer.getMessage("jsp.error.jspc.missingTarget"));
        }
        String firstJsp = (String)pages.get(0);
        File firstJspF = new File(firstJsp);
        if (!firstJspF.exists()) {
          throw new JasperException(Localizer.getMessage("jspc.error.fileDoesNotExist", firstJsp));
        }
        locateUriRoot(firstJspF);
      }
      if (uriRoot == null) {
        throw new JasperException(Localizer.getMessage("jsp.error.jspc.no_uriroot"));
      }
      if (context == null) {
        initServletContext();
      }
      if (pages.size() == 0) {
        scanFiles(new File(uriRoot));
      }
      File uriRootF = new File(uriRoot);
      if ((!uriRootF.exists()) || (!uriRootF.isDirectory())) {
        throw new JasperException(Localizer.getMessage("jsp.error.jspc.uriroot_not_dir"));
      }
      initWebXml();
      
      Iterator iter = pages.iterator();
      while (iter.hasNext())
      {
        String nextjsp = iter.next().toString();
        File fjsp = new File(nextjsp);
        if (!fjsp.isAbsolute()) {
          fjsp = new File(uriRootF, nextjsp);
        }
        if (!fjsp.exists())
        {
          if (log.isWarnEnabled()) {
            log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist", fjsp.toString()));
          }
   
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd