tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler JspReader.java Parser.java ParserController.java
Date Sat, 02 Jun 2001 18:44:45 GMT
remm        01/06/02 11:44:45

  Modified:    jasper/src/share/org/apache/jasper/compiler JspReader.java
                        Parser.java ParserController.java
  Log:
  - When testing with unpackWARs=false, I found areas in Jasper code
    which still used File object, and were broken when Jasper is ran under
    Windows. This patch simplifies the code a bit, and replaces the File objects
    with String objects (the File object was only used to hold the filename).
  - Tested with tester and various JSP examples.
  
  Revision  Changes    Path
  1.6       +3 -7      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JspReader.java	2001/03/21 00:08:51	1.5
  +++ JspReader.java	2001/06/02 18:44:45	1.6
  @@ -240,16 +240,12 @@
       }
       */
   
  -    private void pushFile2(File file, String encoding, 
  +    private void pushFile2(String file, String encoding, 
   			   InputStreamReader reader) 
   	throws ParseException, FileNotFoundException 
       {
   	// Register the file
  -	String longName = (context == null)
  -	    ? file.getAbsolutePath()
  -	    : context.getRealPath(file.toString());
  -        if (longName == null)
  -            longName = file.toString();
  +	String longName = file;
   
   	int fileid = registerSourceFile(longName);
   
  @@ -312,7 +308,7 @@
       }
   	
       protected JspReader(JspCompilationContext ctx,
  -			File file,
  +			String file,
   			String encoding, InputStreamReader reader) 
   	throws ParseException, FileNotFoundException
       {
  
  
  
  1.11      +1 -1      jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Parser.java	2001/04/27 01:32:47	1.10
  +++ Parser.java	2001/06/02 18:44:45	1.11
  @@ -129,7 +129,7 @@
       }
   
       // new constructor for JSP1.2
  -    public Parser(JspCompilationContext ctxt, File file, 
  +    public Parser(JspCompilationContext ctxt, String file, 
   		  String encoding, InputStreamReader inReader, 
   		  final ParseEventListener lnr) 
   	throws ParseException, java.io.FileNotFoundException
  
  
  
  1.15      +16 -31    jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserController.java
  
  Index: ParserController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/ParserController.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ParserController.java	2001/04/09 23:38:12	1.14
  +++ ParserController.java	2001/06/02 18:44:45	1.15
  @@ -183,22 +183,16 @@
   	throws FileNotFoundException, JasperException
       {
           //p("parse(" + inFileName + ")");
  +
           String absFileName = resolveFileName(inFileName);
  -        File file = new File(absFileName);
  -	String filePath = (ctxt == null) 
  -	    ? file.getAbsolutePath()
  -	    : ctxt.getRealPath(file.toString());
  -        if (filePath == null) {
  -            filePath = file.toString();
  -        }
   	//p("filePath: " + filePath);
   
   	String encoding = topFileEncoding;
           InputStreamReader reader = null;
           try {
               // Figure out what type of JSP document we are dealing with
  -            reader = getReader(file, encoding, absFileName);
  -            figureOutJspDocument(file, encoding, reader);
  +            reader = getReader(absFileName, encoding);
  +            figureOutJspDocument(absFileName, encoding, reader);
               //p("isXml = " + isXml + "   hasTaglib = " + hasTaglib);
   	    encoding = (newEncoding!=null) ? newEncoding : encoding;
   	    if (isTopFile) {
  @@ -213,11 +207,11 @@
   
               // dispatch to the proper parser
   	    
  -            reader = getReader(file, encoding, absFileName);
  +            reader = getReader(absFileName, encoding);
               if (isXml) {
  -                (new ParserXJspSax(filePath, reader, jspHandler)).parse();
  +                (new ParserXJspSax(absFileName, reader, jspHandler)).parse();
               } else {
  -                (new Parser(ctxt, file, encoding, reader, jspHandler)).parse();
  +                (new Parser(ctxt, absFileName, encoding, reader, jspHandler)).parse();
               }
   	    baseDirStack.pop();
           } finally {
  @@ -232,7 +226,7 @@
       //*********************************************************************
       // Figure out input Document
   
  -    private void figureOutJspDocument(File file, 
  +    private void figureOutJspDocument(String file, 
   				      String encoding,
   				      InputStreamReader reader)
   	 throws JasperException
  @@ -420,37 +414,28 @@
        * baseDirStack.
        */
       private String resolveFileName(String inFileName) {
  -	File file = new File(inFileName);
  -        boolean isAbsolute = file.getPath().startsWith(File.separator);
  +        boolean isAbsolute = inFileName.startsWith("/");
   	String fileName = 
   	    isAbsolute ?
  -	    inFileName : (String)baseDirStack.peek() + inFileName;
  +	    inFileName : (String) baseDirStack.peek() + inFileName;
   	String baseDir = 
  -	    inFileName.substring(0, file.getPath().lastIndexOf(File.separator) + 1);
  +	    inFileName.substring(0, inFileName.lastIndexOf("/") + 1);
   	baseDirStack.push(baseDir);
   	return fileName;
       }
   
  -    private InputStreamReader getReader(File file, String encoding,
  -					String absFileName)
  +    private InputStreamReader getReader(String file, String encoding)
   	throws FileNotFoundException, JasperException
       {
           InputStream in;
           InputStreamReader reader;
   
   	try {
  -	    if (ctxt == null) {
  -		in = new FileInputStream(file);
  -		reader = new InputStreamReader(in, encoding);
  -	    } else {
  -		//String fileName = ctxt.getRealPath(file.toString());
  -		in = ctxt.getResourceAsStream(file.toString());
  -		if (in == null) {
  -		    throw new FileNotFoundException(absFileName);
  -		}
  -		reader = new InputStreamReader(in, encoding);
  -	    }
  -	    return reader;
  +            in = ctxt.getResourceAsStream(file);
  +            if (in == null) {
  +                throw new FileNotFoundException(file);
  +            }
  +            return new InputStreamReader(in, encoding);
   	} catch (UnsupportedEncodingException ex) {
   	    throw new JasperException(
                   Constants.getString("jsp.error.unsupported.encoding",
  
  
  

Mime
View raw message