You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cm...@mytownnet.com on 2000/03/23 00:05:25 UTC

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

One thing your patch assumes is that the resources are actually stored in
files.  That is commonly the case, but need not be -- you could be running
your web application out of a JAR file, out of a database, or even off of
another web server (Tomcat at one point let you set the document base to
an HTTP URL, which essentially made it into a proxy server).

Based on this, I would suggest this patch not be implemented.

Craig McClanahan


On Wed, 22 Mar 2000, 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
> 


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

Posted by "Anil K. Vijendran" <An...@eng.sun.com>.
Ah. Thanks for remembering this.... I was a bit surprised about how it had changed
because I specifically did a pass a while back to use ctxt.getR.A.S(..) strictly
instead of file ops. I'll change my vote to -1 until we hear from Sam why it was
changed back to getR.P().

I've attached the relevant CVS message.

Danno Ferrin wrote:

>      Sam added it as a patch to fix some win32 bug in 1.12, just three
> weeks ago, and Petr's patch basically totally un-does Sam's patch,
> almost completely reverting the code to the way it was since the
> beginning of time.  I couldn't get the full gist of it from his notes
> but this is certainly a patch that should not be applied speculatively
> (and then I would recommend a simple roll back rather than petr's
> because petr's doesn't change the slash to File.seperator).
>
> Hence I would -1 unless this patch is pounded into the ground first on
> all major platforms (without anything resembling a hiccup), but if sam
> gives a go ahead I will +1 it.  It also needs to be more platform
> neutral (like it was in the beginning of time code).
>
> I agree that making getResourceAsStream would be a better way to do it
> but I just don't see sam patching something that small for kicks and
> giggles, he must have had a reason.
>
> --Danno
>
> Anil Vijendran wrote:
> >
> > In The patch that Petr submitted, he wants to change context.getRealPath(...) to
> > context.getResourceAsStream(...), which would be good for all the reasons you
> > mention.
> >
> > I don't remember why this wasn't done; maybe because command line compilation
> > would break?
> >
> > Anyway +1 for integrating this patch.
> >
> > cmcclanahan@mytownnet.com wrote:
> >
> > > One thing your patch assumes is that the resources are actually stored in
> > > files.  That is commonly the case, but need not be -- you could be running
> > > your web application out of a JAR file, out of a database, or even off of
> > > another web server (Tomcat at one point let you set the document base to
> > > an HTTP URL, which essentially made it into a proxy server).
> > >
> > > Based on this, I would suggest this patch not be implemented.
> > >
> > > Craig McClanahan
> > >
> > > On Wed, 22 Mar 2000, 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
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >
> > --
> > Peace, Anil +<:-)
> >
> > ---------------------------------------------------------------------
> > 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

--
Peace, Anil +<:-)


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

Posted by Danno Ferrin <sh...@earthlink.net>.
     Sam added it as a patch to fix some win32 bug in 1.12, just three
weeks ago, and Petr's patch basically totally un-does Sam's patch,
almost completely reverting the code to the way it was since the
beginning of time.  I couldn't get the full gist of it from his notes
but this is certainly a patch that should not be applied speculatively
(and then I would recommend a simple roll back rather than petr's 
because petr's doesn't change the slash to File.seperator).  

Hence I would -1 unless this patch is pounded into the ground first on
all major platforms (without anything resembling a hiccup), but if sam
gives a go ahead I will +1 it.  It also needs to be more platform
neutral (like it was in the beginning of time code).

I agree that making getResourceAsStream would be a better way to do it
but I just don't see sam patching something that small for kicks and
giggles, he must have had a reason.

--Danno


Anil Vijendran wrote:
> 
> In The patch that Petr submitted, he wants to change context.getRealPath(...) to
> context.getResourceAsStream(...), which would be good for all the reasons you
> mention.
> 
> I don't remember why this wasn't done; maybe because command line compilation
> would break?
> 
> Anyway +1 for integrating this patch.
> 
> cmcclanahan@mytownnet.com wrote:
> 
> > One thing your patch assumes is that the resources are actually stored in
> > files.  That is commonly the case, but need not be -- you could be running
> > your web application out of a JAR file, out of a database, or even off of
> > another web server (Tomcat at one point let you set the document base to
> > an HTTP URL, which essentially made it into a proxy server).
> >
> > Based on this, I would suggest this patch not be implemented.
> >
> > Craig McClanahan
> >
> > On Wed, 22 Mar 2000, 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
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> --
> Peace, Anil +<:-)
> 
> ---------------------------------------------------------------------
> 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 Anil Vijendran <ak...@pipedream.org>.
In The patch that Petr submitted, he wants to change context.getRealPath(...) to
context.getResourceAsStream(...), which would be good for all the reasons you
mention.

I don't remember why this wasn't done; maybe because command line compilation
would break?

Anyway +1 for integrating this patch.

cmcclanahan@mytownnet.com wrote:

> One thing your patch assumes is that the resources are actually stored in
> files.  That is commonly the case, but need not be -- you could be running
> your web application out of a JAR file, out of a database, or even off of
> another web server (Tomcat at one point let you set the document base to
> an HTTP URL, which essentially made it into a proxy server).
>
> Based on this, I would suggest this patch not be implemented.
>
> Craig McClanahan
>
> On Wed, 22 Mar 2000, 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
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

--
Peace, Anil +<:-)