You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Costin Manolache <co...@eng.sun.com> on 2000/03/22 16:36:51 UTC

Re: [PATCH] JspReader: using getResourceAsStream() instead of getRealPath()

The only reason for using getRealPath is to check if the file was modified and
needs recompilation.

There is no way to do that with getResource - the lastModified method in URL is
broken ( doesn't work in most cases ).

URL is not equivalent with File.

Costin

Petr Jiricka wrote:

> Hello,
>
> I was wandering if it would pe possible to apply the following patch:
>
> RCS file:
> /home/cvspublic/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReade
> r.java,v
> retrieving revision 1.12
> diff -u -r1.12 JspReader.java
> --- JspReader.java      2000/02/27 16:46:34     1.12
> +++ JspReader.java      2000/03/22 11:08:36
> @@ -152,8 +152,10 @@
>                  reader = new InputStreamReader(new FileInputStream(file),
>                                                 encoding);
>              else {
> +                InputStream in =
> context.getResourceAsStream(file.toString());
>                 String fileName = context.getRealPath(file.toString());
> -                InputStream in = new FileInputStream(fileName);
> +                if (fileName == null)
> +                    fileName = file.toString();
>                  if (in == null)
>                      throw new FileNotFoundException(fileName);
>
> Would it break anything ? My impression is that
>
> context.getResourceAsStream(uri) and
>
> new FileInputStream(getRealPath(uri))
>
> should be the same thing. Switching to getResourceAsStream() would allow
> more flexibility, things like parsing JSP files from non-file sources (such
> as Swing documents), and more general approach to JSP parsing in general.
>
> Thanks
> Petr
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org