You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Philippe Lavoie <ph...@cactus.ca> on 2000/01/19 00:46:55 UTC
[Bugfix] Relative path problem under JRun
As mentionned in the mailing list, there is a problem in determining the
relative path
of a file with JRun with the following patch it works.
I have absolutely no clue why the new code doesn't work properly. Because
the more I look at the solution, the less I see differences. Perhaps someone
can show me the difference between the two versions of that piece of code?
Anyway, with that fix you can add JRun2.3.3 under windows NT as a supported
platform for 1.6.
Phil
*** ProducerFromFile.java Tue Jan 18 18:45:40 2000
--- ProducerFromFile.java~ Tue Jan 18 14:25:20 2000
*************** public class ProducerFromFile extends Ab
*** 107,122 ****
}
} catch (NoSuchMethodError e) {
// if there is no such method we must be in Servlet API 2.1
! return ((request.getPathInfo() == null)
! ? request.getRealPath(request.getRequestURI())
! : request.getPathTranslated()).replace('\\','/');
! } catch (MalformedURLException e) {
throw new RuntimeException("Malformed request URL.");
} catch (NullPointerException e) {
// if there is no context set, we must be called from the
command line
return request.getPathTranslated().replace('\\','/');
}
-
}
public String getStatus() {
--- 107,125 ----
}
} catch (NoSuchMethodError e) {
// if there is no such method we must be in Servlet API 2.1
! if (request.getPathInfo() != null) {
! // this must be Apache JServ
! return request.getPathTranslated().replace('\\','/');
! } else {
! // otherwise use the deprecated method on all other
servlet engines.
! return request.getRealPath(request.getRequestURI());
! }
! } catch (MalformedURLException e) {
throw new RuntimeException("Malformed request URL.");
} catch (NullPointerException e) {
// if there is no context set, we must be called from the
command line
return request.getPathTranslated().replace('\\','/');
}
}
Re: [Bugfix] Relative path problem under JRun
Posted by lu...@networks.vivendi.net.
Stefano Mazzocchi wrote:
>
> Philippe Lavoie wrote:
> >
> > *** ProducerFromFile.java Tue Jan 18 18:45:40 2000
> > --- ProducerFromFile.java~ Tue Jan 18 14:25:20 2000
> > *************** public class ProducerFromFile extends Ab
> > *** 107,122 ****
> > }
> > } catch (NoSuchMethodError e) {
> > // if there is no such method we must be in Servlet API 2.1
> > ! return ((request.getPathInfo() == null)
> > ! ? request.getRealPath(request.getRequestURI())
> > ! : request.getPathTranslated()).replace('\\','/');
> > ! } catch (MalformedURLException e) {
> > throw new RuntimeException("Malformed request URL.");
> > } catch (NullPointerException e) {
> > // if there is no context set, we must be called from the
> > command line
> > return request.getPathTranslated().replace('\\','/');
> > }
> > -
> > }
> >
> > public String getStatus() {
> > --- 107,125 ----
> > }
> > } catch (NoSuchMethodError e) {
> > // if there is no such method we must be in Servlet API 2.1
> > ! if (request.getPathInfo() != null) {
> > ! // this must be Apache JServ
> > ! return request.getPathTranslated().replace('\\','/');
> > ! } else {
> > ! // otherwise use the deprecated method on all other
> > servlet engines.
> > ! return request.getRealPath(request.getRequestURI());
> > ! }
> > ! } catch (MalformedURLException e) {
> > throw new RuntimeException("Malformed request URL.");
> > } catch (NullPointerException e) {
> > // if there is no context set, we must be called from the
> > command line
> > return request.getPathTranslated().replace('\\','/');
> > }
> > }
>
> I'm probably missing something but this patch is totally equivalent.
>
No. replace() is not called on the result of getRealPath() in the patched
version.
--
Raphaƫl Luta - luta.raphael@networks.vivendi.net
Re: [Bugfix] Relative path problem under JRun
Posted by Stefano Mazzocchi <st...@apache.org>.
Philippe Lavoie wrote:
>
> As mentionned in the mailing list, there is a problem in determining the
> relative path
> of a file with JRun with the following patch it works.
>
> I have absolutely no clue why the new code doesn't work properly. Because
> the more I look at the solution, the less I see differences. Perhaps someone
> can show me the difference between the two versions of that piece of code?
> Anyway, with that fix you can add JRun2.3.3 under windows NT as a supported
> platform for 1.6.
>
> Phil
>
> *** ProducerFromFile.java Tue Jan 18 18:45:40 2000
> --- ProducerFromFile.java~ Tue Jan 18 14:25:20 2000
> *************** public class ProducerFromFile extends Ab
> *** 107,122 ****
> }
> } catch (NoSuchMethodError e) {
> // if there is no such method we must be in Servlet API 2.1
> ! return ((request.getPathInfo() == null)
> ! ? request.getRealPath(request.getRequestURI())
> ! : request.getPathTranslated()).replace('\\','/');
> ! } catch (MalformedURLException e) {
> throw new RuntimeException("Malformed request URL.");
> } catch (NullPointerException e) {
> // if there is no context set, we must be called from the
> command line
> return request.getPathTranslated().replace('\\','/');
> }
> -
> }
>
> public String getStatus() {
> --- 107,125 ----
> }
> } catch (NoSuchMethodError e) {
> // if there is no such method we must be in Servlet API 2.1
> ! if (request.getPathInfo() != null) {
> ! // this must be Apache JServ
> ! return request.getPathTranslated().replace('\\','/');
> ! } else {
> ! // otherwise use the deprecated method on all other
> servlet engines.
> ! return request.getRealPath(request.getRequestURI());
> ! }
> ! } catch (MalformedURLException e) {
> throw new RuntimeException("Malformed request URL.");
> } catch (NullPointerException e) {
> // if there is no context set, we must be called from the
> command line
> return request.getPathTranslated().replace('\\','/');
> }
> }
I'm probably missing something but this patch is totally equivalent.
???
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
Come to the first official Apache Software Foundation Conference!
------------------------- http://ApacheCon.Com ---------------------