remm        2002/05/31 17:43:01

  Modified:    jasper2/src/share/org/apache/jasper JspEngineContext.java
  Log:
  - Remove the normalization (this doesn't sound too useful, esp in 4.1).
  
  Revision  Changes    Path
  1.11      +81 -115   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java
  
  Index: JspEngineContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JspEngineContext.java     31 May 2002 21:11:02 -0000      1.10
  +++ JspEngineContext.java     1 Jun 2002 00:43:01 -0000       1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
 1.10 2002/05/31 21:11:02 remm Exp $
  - * $Revision: 1.10 $
  - * $Date: 2002/05/31 21:11:02 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspEngineContext.java,v
 1.11 2002/06/01 00:43:01 remm Exp $
  + * $Revision: 1.11 $
  + * $Date: 2002/06/01 00:43:01 $
    *
    * ====================================================================
    * 
  @@ -101,7 +101,13 @@
    * @author Glenn Nielsen
    * @author Remy Maucherat
    */
  -public class JspEngineContext implements JspCompilationContext {
  +public class JspEngineContext 
  +    implements JspCompilationContext {
  +
  +
  +    // ----------------------------------------------------- Instance Variables
  +
  +
       private JspReader reader;
       private ServletWriter writer;
       private ServletContext context;
  @@ -125,10 +131,15 @@
       private int removed = 0;
       private JspServletWrapper jsw;
   
  +
  +    // ------------------------------------------------------------ Constructor
  +
  +
       public JspEngineContext(JspRuntimeContext rctxt, ServletContext context,
                               String jspUri, JspServletWrapper jsw,
                               boolean isErrPage, Options options)
  -            throws JasperException {
  +        throws JasperException {
  +
           this.rctxt = rctxt;
           this.context = context;
           this.jspUri = jspUri;
  @@ -139,61 +150,45 @@
   
           createOutdir();
           createCompiler();
  -    }
   
  -    private void createOutdir() {
  -        File outDir = null;
  -        try {
  -            URL outURL = options.getScratchDir().toURL();
  -            String outURI = outURL.toString();
  -            if( outURI.endsWith("/") ) {
  -                outURI = outURI +
  -                         jspUri.substring(1,jspUri.lastIndexOf("/")+1);
  -            } else {
  -                outURI = outURI +
  -                         jspUri.substring(0,jspUri.lastIndexOf("/")+1);;
  -            }
  -            outURL = new URL(outURI);
  -            outDir = new File(normalize(outURL.getFile()));
  -            if( !outDir.exists() ) {
  -                outDir.mkdirs();
  -            }
  -            this.outDir = outDir.toString() + File.separator;
  -            outUrls[0] = new URL(outDir.toURL().toString() + File.separator);
  -        } catch(Exception e) {
  -            throw new IllegalStateException("No output directory: " +
  -                                            e.getMessage());
  -        }
       }
   
  +
  +    // ------------------------------------------ JspCompilationContext Methods
  +
  +
       /**
        * The classpath that is passed off to the Java compiler. 
        */
       public String getClassPath() {
           return rctxt.getClassPath();
       }
  -    
  +
  +
       /**
        * Get the input reader for the JSP text. 
        */
       public JspReader getReader() { 
           return reader;
       }
  -    
  +
  +
       /**
        * Where is the servlet being generated?
        */
       public ServletWriter getWriter() {
           return writer;
       }
  -    
  +
  +
       /**
        * Get the ServletContext for the JSP we're processing now. 
        */
       public ServletContext getServletContext() {
           return context;
       }
  -    
  +
  +
       /**
        * The class loader to use for loading classes while compiling
        * this JSP.
  @@ -202,6 +197,7 @@
           return rctxt.getParentClassLoader();
       }
   
  +
       /**
        * Return true if the current page is an errorpage.
        */
  @@ -212,8 +208,6 @@
   
       /**
        * What is the scratch directory we are generating code into?
  -     * FIXME: In some places this is called scratchDir and in some
  -     * other places it is called outputDir.
        */
       public String getOutputDir() {
           return outDir;
  @@ -221,17 +215,6 @@
   
   
       /**
  -     * Get the scratch directory to place generated code for javac.
  -     *
  -     * FIXME: In some places this is called scratchDir and in some
  -     * other places it is called outputDir.
  -     */
  -    public String getJavacOutputDir() {
  -        return null;
  -    }
  -
  -
  -    /**
        * Path of the JSP URI. Note that this is not a file name. This is
        * the context rooted URI of the JSP file. 
        */
  @@ -338,6 +321,7 @@
           return contentType;
       }
   
  +
       /**
        * Get hold of the Options object for this context. 
        */
  @@ -350,30 +334,37 @@
           this.contentType = contentType;
       }
   
  +
       public void setReader(JspReader reader) {
           this.reader = reader;
       }
  -    
  +
  +
       public void setWriter(ServletWriter writer) {
           this.writer = writer;
       }
  -    
  +
  +
       public void setServletClassName(String servletClassName) {
           this.servletClassName = servletClassName;
       }
  -    
  +
  +
       public void setServletPackageName(String servletPackageName) {
           this.servletPackageName = servletPackageName;
       }
   
  +
       public void setServletJavaFileName(String servletJavaFileName) {
           this.servletJavaFileName = servletJavaFileName;
       }
  -    
  +
  +
       public void setErrorPage(boolean isErrPage) {
           this.isErrPage = isErrPage;
       }
   
  +
       public Compiler createCompiler() throws JasperException {
   
           if (jspCompiler != null ) {
  @@ -385,6 +376,7 @@
   
       }
   
  +
       public void compile() throws JasperException, FileNotFoundException {
   
           if (jspCompiler.isOutDated()) {
  @@ -398,7 +390,9 @@
           }
       }
   
  -    public Class load() throws JasperException, FileNotFoundException {
  +
  +    public Class load() 
  +        throws JasperException, FileNotFoundException {
   
           try {
               if (servletClass == null && !options.getDevelopment()) {
  @@ -429,10 +423,12 @@
           return servletClass;
       }
   
  +
       public boolean isReload() {
           return reload;
       }
   
  +
       public void incrementRemoved() {
           if (removed > 1) {
               jspCompiler.removeGeneratedFiles();
  @@ -441,6 +437,7 @@
           removed++;
       }
   
  +
       public boolean isRemoved() {
           if (removed > 1 ) {
               return true;
  @@ -448,6 +445,7 @@
           return false;
       }
   
  +
       /** 
        * Get the full value of a URI relative to this compilations context
        */
  @@ -458,6 +456,7 @@
           return baseURI + uri;
       }
   
  +
       /**
        * Gets a resource as a stream, relative to the meanings of this
        * context's implementation.
  @@ -468,10 +467,12 @@
           return context.getResourceAsStream(res);
       }
   
  +
       public URL getResource(String res) throws MalformedURLException {
           return context.getResource(res);
       }
   
  +
       /** 
        * Gets the actual path of a URI relative to the context of
        * the compilation.
  @@ -483,76 +484,13 @@
           return path;
       }
   
  +
       public String[] getTldLocation(String uri) throws JasperException {
        String[] location = 
            options.getTldLocationsCache().getLocation(uri);
        return location;
       }
   
  -    /**
  -     * Return a context-relative path, beginning with a "/", that represents
  -     * the canonical version of the specified path after ".." and "." elements
  -     * are resolved out.  If the specified path attempts to go outside the
  -     * boundaries of the current context (i.e. too many ".." path elements
  -     * are present), return <code>null</code> instead.
  -     *
  -     * @param path Path to be normalized
  -     */
  -    protected String normalize(String path) {
  -
  -        if (path == null) {
  -            return null;
  -        }
  -
  -        String normalized = path;
  -
  -        // Normalize the slashes and add leading slash if necessary
  -        if (normalized.indexOf('\\') >= 0) {
  -            normalized = normalized.replace('\\', '/');
  -        }
  -        if (!normalized.startsWith("/")) {
  -            normalized = "/" + normalized;
  -        }
  -
  -        // Resolve occurrences of "//" in the normalized path
  -        while (true) {
  -            int index = normalized.indexOf("//");
  -            if (index < 0) {
  -                break;
  -            }
  -            normalized = normalized.substring(0, index) +
  -                normalized.substring(index + 1);
  -        }
  -
  -        // Resolve occurrences of "/./" in the normalized path
  -        while (true) {
  -            int index = normalized.indexOf("/./");
  -            if (index < 0) {
  -                break;
  -            }
  -            normalized = normalized.substring(0, index) +
  -                normalized.substring(index + 2);
  -        }
  -
  -        // Resolve occurrences of "/../" in the normalized path
  -        while (true) {
  -            int index = normalized.indexOf("/../");
  -            if (index < 0) {
  -                break;
  -            }
  -            if (index == 0) {
  -                return (null);  // Trying to go outside our context
  -            }
  -            int index2 = normalized.lastIndexOf('/', index - 1);
  -            normalized = normalized.substring(0, index2) +
  -                normalized.substring(index + 3);
  -        }
  -
  -        // Return the normalized path that we have completed
  -        return (normalized);
  -
  -    }
  -
   
       public final String getClassFileName() {
   
  @@ -569,6 +507,34 @@
   
       }
   
  +
  +    // -------------------------------------------------------- Private Methods
  +
  +
  +    private void createOutdir() {
  +        File outDir = null;
  +        try {
  +            URL outURL = options.getScratchDir().toURL();
  +            String outURI = outURL.toString();
  +            if( outURI.endsWith("/") ) {
  +                outURI = outURI +
  +                         jspUri.substring(1,jspUri.lastIndexOf("/")+1);
  +            } else {
  +                outURI = outURI +
  +                         jspUri.substring(0,jspUri.lastIndexOf("/")+1);;
  +            }
  +            outURL = new URL(outURI);
  +            outDir = new File(outURL.getFile());
  +            if (!outDir.exists()) {
  +                outDir.mkdirs();
  +            }
  +            this.outDir = outDir.toString() + File.separator;
  +            outUrls[0] = new URL(outDir.toURL().toString() + File.separator);
  +        } catch (Exception e) {
  +            throw new IllegalStateException("No output directory: " +
  +                                            e.getMessage());
  +        }
  +    }
   
       /**
        * Mangle the specified character to create a legal Java class name.
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to