You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jaynika Barot <ja...@gmail.com> on 2005/07/25 17:02:46 UTC
Tomcat filter to overwrite the requestURL of incoming httprequest object
hi all,
I want to write a filter which will overwrite the request URL in
incoming httprequest.
if incoming request's URI contains *./myservletName/extra1/extra2.*
I want to reset it to *./myservletName?param1=extra1¶m2=extra2 and
pass this request object to subsequent processing (filter chain).
Is it possible to do?? If so how?
thx,
Jaynika
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Tomcat filter to overwrite the requestURL of incoming httprequest
object
Posted by Martin Bromley <ma...@sustainable-energy.co.uk>.
You have to wrap the HttpServletRequest with a class that overrides the methods relating to the URI. I've attached an abstract class that I wrote to make this a bit easier.
You will have to implement the rewriteURL method to do the necessary String parsing.
Then in your filter doFilter:
chain.doFilter(new WrappedRequest(request), response);
(assuming you've written WrappedRequest - that extends the abstract class I've attached).
Good luck.
Martin
PS You're question actually has nothing to do with Tomcat specifically...
Jaynika Barot wrote:
> hi all,
>
> I want to write a filter which will overwrite the request URL in
> incoming httprequest.
>
> if incoming request's URI contains *./myservletName/extra1/extra2.*
>
> I want to reset it to *./myservletName?param1=extra1¶m2=extra2 and
> pass this request object to subsequent processing (filter chain).
>
> Is it possible to do?? If so how?
>
> thx,
> Jaynika
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>