tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <devli...@hanik.com>
Subject Re: ClassCastException when forwarding wrapped HttpServletRequest
Date Mon, 22 May 2006 14:20:08 GMT
I remember seeing the spec that you can't do this, you have to provide a 
ServletRequestWrapper implementation

Filip


Yuri de Wit wrote:
> 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).
>
> 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.
>
> 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?
>
> Is there a safer way of implementing the functionlity I described above?
>
> thanks.
> - yuri
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message