luehe       2002/10/07 12:36:18

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        ParserController.java
  Log:
  Improved error reporting for missing tag file in jar
  
  Revision  Changes    Path
  1.21      +22 -27    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
  
  Index: ParserController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ParserController.java     15 Sep 2002 23:12:30 -0000      1.20
  +++ ParserController.java     7 Oct 2002 19:36:18 -0000       1.21
  @@ -77,15 +77,10 @@
    * @author Pierre Delisle
    */
   public class ParserController {
  -    /*
  -     * The compilation context
  -     */
  -    private JspCompilationContext ctxt;
   
  -    /*
  -     * The Compiler
  -     */
  +    private JspCompilationContext ctxt;
       private Compiler compiler;
  +    private ErrorDispatcher err;
   
       /*
        * A stack to keep track of the 'current base directory'
  @@ -124,12 +119,13 @@
       private String newEncoding;
   
   
  -    //*********************************************************************
  -    // Constructor
  -
  +    /*
  +     * Constructor
  +     */
       public ParserController(JspCompilationContext ctxt, Compiler compiler) {
           this.ctxt = ctxt; // @@@ can we assert that ctxt is not null?
        this.compiler = compiler;
  +     this.err = compiler.getErrorDispatcher();
       }
   
       public JspCompilationContext getJspCompilationContext () {
  @@ -140,9 +136,6 @@
        return compiler;
       }
   
  -    //*********************************************************************
  -    // Parse
  -
       /**
        * Parses a jsp file.  This is invoked by the compiler.
        *
  @@ -228,8 +221,7 @@
                                                     isTagFile);
               } else {
                JspReader r = new JspReader(ctxt, absFileName, encoding,
  -                                         reader,
  -                                         compiler.getErrorDispatcher());
  +                                         reader, err);
                   parsedPage = Parser.parse(this, r, parent, isTagFile,
                                          directivesOnly);
               }
  @@ -281,8 +273,7 @@
   
        JspReader jspReader;
        try {
  -         jspReader = new JspReader(ctxt, file, encoding, reader,
  -                                   compiler.getErrorDispatcher());
  +         jspReader = new JspReader(ctxt, file, encoding, reader, err);
        } catch (FileNotFoundException ex) {
            throw new JasperException(ex);
        }
  @@ -362,28 +353,32 @@
   
       private InputStreamReader getReader(String file, String encoding,
                                        JarFile jarFile)
  -     throws FileNotFoundException, JasperException, IOException {
  +             throws JasperException, IOException {
   
  -        InputStream in;
  -        InputStreamReader reader;
  +        InputStream in = null;
  +        InputStreamReader reader = null;
   
        if (jarFile != null) {
  -         ZipEntry jarEntry =
  -             jarFile.getEntry(file.substring(1, file.length()));
  +         String jarEntryName = file.substring(1, file.length());
  +         ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
  +         if (jarEntry == null) {
  +             err.jspError("jsp.error.file.not.found", file);
  +         }
            in = jarFile.getInputStream(jarEntry);
        } else {
            in = ctxt.getResourceAsStream(file);
        }
  +
        if (in == null) {
  -         throw new FileNotFoundException(file);
  +         err.jspError("jsp.error.file.not.found", file);
        }
   
        try {
  -            return new InputStreamReader(in, encoding);
  +            reader = new InputStreamReader(in, encoding);
        } catch (UnsupportedEncodingException ex) {
  -         throw new JasperException(
  -                Constants.getString("jsp.error.unsupported.encoding",
  -                                 new Object[]{encoding}));
  +         err.jspError("jsp.error.unsupported.encoding", encoding);
        }
  +
  +     return reader;
       }
   }
  
  
  

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

Reply via email to