>"Yuri de Wit" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >I am not sure I should have posted this question to the dev mailing list, >let me know if that should be the case. > >I am using Tomcat 5.5.16. > >I have a series of chained HttpServlets in my web app. The first servlet is >registered with the web.xml and the following ones are dispatched manually. >Before delegating the HTTP request to the next internal servlet, I am >wrapping the HttpServletRequest overriding getPathInfo() and >getServletPath(). If the pathInfo was /a/b and servletPath was /x, after >wrapping the request getPathInfo returns /b and the servletPath returns >/x/a. The reason I am doing this is that I would like forward and includes >to work relative to my internal pathInfo and servletPath (/b and /x/a) >instead of the web container one (/a/b and /x). >
I assume that 'dispatched manually' means you are using getNamedDispatcher? >The first problem I encountered was that if I implemented the wrapper by >subclassing HttpServletRequestWrapper Tomcat implementation unwraps it >before forwarding and the final url contains the original path info >appended >and my custom path info. > Not strictly true. Tomcat injects it's wrapper below yours. It's an edge case, but it definitely a bug. Tomcat shouldn't be trusting the wrapper to give it back the correct values. Feel free to open up a BZ report (and, even better if it includes a simple example to reproduce :). >So I then changed my implementation and now I am wrapping the request using >my own subclass of HttpServletRequest instead. Now the problem is that I >get >a ClassCast exception @ org.apache.catalina.core.ApplicationDispatcher line >814 ("current = ((ServletRequestWrapper) current).getRequest();"). > >Shouldnt that casting be conditional? > Nope. Passing anything other than a ServletRequestWrapper or the orginal Request object is specifically forbidden by the Servlet spec. >Is there a safer way of implementing the functionlity I described above? > >thanks. >- yuri > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]