You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stuart Roebuck <sr...@adolos.com> on 2000/07/14 14:53:20 UTC
CoocoonServlet.java, getServletPath() and TomCat
Final followup to my previous postings...
Yesterday's update to CocoonServlet.java appears to break things under
TomCat 3.1.
Given a URL of:
http://www.site.com/path/to/context/subdir/page.html?query
I think the code
uri = getServletPath()
which used to be:
uri = getPathInfo()
is intended to return:
/subdir/page.html
Under TomCat 3.1, getPathInfo() works, but getServletPath() returns an
empty string.
In my mind the Servlet 2.2 spec. would imply that getPathInfo() was the
correct method to use. Therefore, why not either:
1. Use context.getServerInfo() to check for specific cases like "Gefian
LWS and Orion" and return getServletPath() for them only.
2. Check to see whether
uri =
req.getRequestURI().substring(req.getContextPath().length());
is a possible alternative (it works under Tomcat 3.1, but I don't know
about the rest).
Hope this is helpful,
Stuart.
Re: CoocoonServlet.java, getServletPath() and TomCat
Posted by Berin Loritsch <bl...@infoplanning.com>.
Stuart Roebuck wrote:
>
> Under TomCat 3.1, getPathInfo() works, but getServletPath() returns an
> empty string.
:(
Many servlet vendors don't implement getPathInfo for some reason. But I
think they pretty much all support getRequestURI.
>
> In my mind the Servlet 2.2 spec. would imply that getPathInfo() was the
> correct method to use.
This is the response from Gefion's tech team.
This is an area of the spec that has always been interpreted in
different ways by different vendors. We have recently discussed this
in the servlet specification group, and for a servlet mapped to the /
pattern, the context relative path shall be returned by the getServletPath()
method and getPathInfo() returns null. If this is not what Tomcat
returns, it's a bug in Tomcat.
Hans
--
Hans Bergsten hans@gefionsoftware.com
Gefion Software http://www.gefionsoftware.com
> Therefore, why not either:
>
> 1. Use context.getServerInfo() to check for specific cases like "Gefian
> LWS and Orion" and return getServletPath() for them only.
-1. The added checking shouldn't be necessary. Your second proposal will
work.
> 2. Check to see whether
> uri =
> req.getRequestURI().substring(req.getContextPath().length());
> is a possible alternative (it works under Tomcat 3.1, but I don't know
> about the rest).
+1. I already know that getRequestURI works with all three vendors I tried.
Of course, when I didn't do the substring method I needed to be in the
root context.
>
> Hope this is helpful,
It is. The req.getRequestURI method works without problem. In fact, the
tech folks at Gefion suggested the use of either getServletPath or getRequestURI.
They suggested the getServletPath method for servlets that were to be mapped
to '/'.