Duane Morse wrote:
> Certain path-related methods seem to return curious results in JRun 3.0
> after servlet mapping. For instance,
> if I map "/xyz" to "MyServlet", then getPathInfo() returns null,
> getServletPath() returns "/xyz", and
> getRequestURI() returns "/MyApp/xyz". Of course, when invoking MyServlet by
> "/MyApp/servlet/MyServlet/xyz",
> getPathInfo() returns "/xyz", getServletPath() returns "/servlet/MyServlet",
> and getRequestURI() returns
> "/MyApp/servlet/MyServlet/xyz", which is what I expect.
>
> Are these results normal, or is JRun not following the spec?
>
Support for the "invoker" capability (i.e. a mapping to "/servlet/*") is not a
part of the servlet specification at all, so there is no guarantee of
portability. However, the results you are seeing from JRun above are exactly
what you would also see from Tomcat.
The only portability guarantee you have is to use <servlet-mapping> entries
explicitly. If you want to make your mapped servlet accept path information,
make the mapping entry look like this:
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/xyz/*</url-pattern>
</servlet-mapping>
and then a request for "/MyApp/xyz/foo/bar" will return the following values:
* getRequestURI() --> "/MyApp/xyz/foo/bar"
* getContextPath() --> "/MyApp"
* getServletPath() --> "/xyz"
* getPathInfo() --> "/foo/bar"
Note that, other than differences for URL encoding, the following equation is
always true:
RequestURI = ContextPath + ServletPath + PathInfo
>
> Duane Morse, Eldorado Computing Inc., Phoenix Arizona
>
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html