cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Muc <alex....@utoronto.ca>
Subject A bug and a fix in FileProducer.java
Date Wed, 01 Dec 1999 10:21:16 GMT
Hi,

I've been playing around with cocoon over the last few days using
JSWDK-1.0 on my windows 95 machine with JDK1.2.2.  I have been having
some problems just getting the basic demos to work (hello.xml, etc.).  I
have cocoon setup and configured correctly in my classpath.  In my
webserver.xml file (which is the file which tells JSWDK-1.0 about it's
server configuration) I had the following to setup the cocoon web
application:
<WebApplication id="cocoon" mapping="/co" docBase="cocoonwork"/>

When I made a request to the hello.xml example I got the following
error:
Error found handling the request.
      java.io.FileNotFoundException:
C:\java\jswdk-1.0\cocoonwork\co\example\hello\hello.xml (The system
cannot find the path specified)

The problem is that cocoon is putting the "\co" directory in the path.
On my system the path to the hello.xml example is:
C:\java\jswdk-1.0\cocoonwork\example\hello\hello.xml
(Note:  The only difference between this and the path in the error
message is that this path is missing the "\co" in middle of it and it
really maps to a directory on my file system).

I traced the problem back to the FileProducer.java file and in
particular the getBaseName(HttpServletRequest request) function.  Below
is the function body (I've numbered the lines to make it easier to refer
to):
10  return ((request.getPathInfo() == null)
20     ? request.getRealPath(request.getRequestURI())
30     : request.getPathTranslated()).replace('\\','/');

The problem seems to be that the call to request.getRealPath() with the
value of request.getRequestURI() returns the wrong string (line 20).  I
did some poking around and the request.getRealPath() function call is
deprecated in the servlet API that ships with JSWDK-1.0.  This is one of
the problems.  The main problem though is that the call to
request.getRequestURI() returns a string which in JSWDK-1.0 includes
mapping directory (in my case: "/co"), which I don't think it should
because it can be any string you make up and specify within the
webserver.xml file ("mydirectorymappingonmyserverontuesday" is ok in the
webserver.xml file, and it doesn't have to map to anything in the actual
file system).  I think line 20 should read:
       ? request.getRealPath(request.getServletPath())

The call to request.getServletPath() returns just the path information,
and none of the directory mapping info (the "/co" stuff in my case).

I don't know for sure if this is a bug or it was designed on purpose
this way (I'm pretty sure it's a bug), but one thing for sure is that on
my system only a call to request.getServletPath() works properly, and
calling request.getRequestURI() doesn't work properly.  I think the
above suggestion fixes the problem too.

I hope this is some use to someone.  If you want to discuss this more
feel free to contact me.

Sorry about the length of this message.

Cheers.
Alex Muc.



Mime
View raw message