tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bucknam, Brian" <Brian.Buck...@webgain.com>
Subject RE: cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/ja sper/compiler TagLibraryInfoImpl.java
Date Thu, 25 Jan 2001 20:41:57 GMT
Why not try to continue if getRealPath() returns null?  The Servlet 2.2 spec
allows containers to return null if they feel like it.  (Haven't checked
this in 2.3).

That is, how about something more forgiving like this instead:
        try {
            // see if file exists on the filesystem first
            String real = ctxt.getRealPath(uri);
            if (real != null) new FileInputStream(real);
        }
        catch (FileNotFoundException ex) {
            // if file not found on filesystem, get the resource through
            // the context
        }
        return ctxt.getResourceAsStream(uri);


Brian
-------------------------
Brian Bucknam
WebGain, Inc.
brian.bucknam@webgain.com

> -----Original Message-----
> From: horwat@apache.org [mailto:horwat@apache.org]
> Sent: Wednesday, January 24, 2001 6:46 PM
> To: jakarta-tomcat-4.0-cvs@apache.org
> Subject: cvs commit:
> jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler
> TagLibraryInfoImpl.java
> 
> 
> horwat      01/01/24 18:46:03
> 
>   Modified:    jasper/src/share/org/apache/jasper/compiler
>                         TagLibraryInfoImpl.java
>   Log:
>   If real file does exist, use the context to get the resource.
>   
>   Revision  Changes    Path
>   1.17      +11 -9     
> jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler
/TagLibraryInfoImpl.java
>   
>   Index: TagLibraryInfoImpl.java
>   ===================================================================
>   RCS file: 
> /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jaspe
r/compiler/TagLibraryInfoImpl.java,v
>   retrieving revision 1.16
>   retrieving revision 1.17
>   diff -u -r1.16 -r1.17
>   --- TagLibraryInfoImpl.java	2000/12/08 20:45:12	1.16
>   +++ TagLibraryInfoImpl.java	2001/01/25 02:46:02	1.17
>   @@ -1,7 +1,7 @@
>    /*
>   - * $Header: 
> /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jaspe
r/compiler/TagLibraryInfoImpl.java,v 1.16 2000/12/08 20:45:12 pierred Exp $
>   - * $Revision: 1.16 $
>   - * $Date: 2000/12/08 20:45:12 $
>   + * $Header: 
> /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jaspe
r/compiler/TagLibraryInfoImpl.java,v 1.17 2001/01/25 02:46:02 horwat Exp $
>   + * $Revision: 1.17 $
>   + * $Date: 2001/01/25 02:46:02 $
>     *
>     * The Apache Software License, Version 1.1
>     *
>   @@ -150,15 +150,17 @@
>        private InputStream getResourceAsStream(String uri) 
>            throws FileNotFoundException 
>        {
>   -        if (uri.indexOf(":") > 0) {
>   -            // may be fully qualified (Windows) or may be 
> a URL.  Let
>   -            // getResourceAsStream deal with it.
>   -            return ctxt.getResourceAsStream(uri);
>   -        } else {
>   -            // assume it translates to a real file, and 
> use getRealPath
>   +        try {
>   +            // see if file exists on the filesystem first
>                String real = ctxt.getRealPath(uri);
>                return (real == null) ? null : new 
> FileInputStream(real);
>            }
>   +        catch (FileNotFoundException ex) {
>   +            // if file not found on filesystem, get the 
> resource through
>   +            // the context
>   +            return ctxt.getResourceAsStream(uri);
>   +        }
>   +       
>        }
>    
>        public TagLibraryInfoImpl(JspCompilationContext ctxt, 
> String prefix, 
>   
>   
>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
> 

Mime
View raw message