You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Petr Jiricka <pe...@netbeans.com> on 2000/03/22 19:28:05 UTC

RE: [PATCH] JspReader: using getResourceAsStream() instead of ge tRealPath()

Yes, but lastModified() is not used in this particular case. It is only used
in JspCompiler.isOutDated() and JspReader is quite independent of this.
JspCompiler can use getRealPath(), but I think JspReader could use
getResourceAsStream(). If I only want to parse a JSP without compiling it, I
don't need to use JspCompiler, so the parser itself does not need to depend
on lastModified().

Also, I think JspCompiler could be changed to support non-File JSPs, if we
say that such JSPs will not be recompiled after modification. It could check
whether getRealPath() is non-null, and if it is null and the class file
exists, the JSP would be up to date. This change could mean that the JSP
compiler supports all docBases (as the servlet engine does), not only
file:// docBases. This would be useful if for example you wanted to serve
your JSPs from a database instead of a local filesystem.

Petr

> -----Original Message-----
> From: Costin Manolache [mailto:costin@eng.sun.com]
> Sent: Wednesday, March 22, 2000 4:37 PM
> To: tomcat-dev@jakarta.apache.org
> Subject: 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/com
> piler/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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 

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

Posted by Eduardo Pelegri--Llopart <Ed...@eng.sun.com>.
A number of vendors are interested in this type of functionality, so it would be
very nice if the code enabled it.

    - eduard/o

Petr Jiricka wrote:

> This would be useful if for example you wanted to serve
> your JSPs from a database instead of a local filesystem.
>
> Petr