File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Modify request URI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Modify request URI" Watch "Modify request URI" New topic

Modify request URI

Robert Garrido
Ranch Hand

Joined: Dec 11, 2008
Posts: 30

I'm implementing a complex filter, this filter receives request from many clients and for some reason some clients send requests with the URI duplicated like this:


I can't touch the code of the clients, but I need to change the incoming URI to

now, in my filter method

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
//I process the URI here
chain(requests, response);

Since there's no httpResponse.setURI() method, How can I change the incoming request URI?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Wouldnt that be a job for a custom HttpServletRequestWrapper that redifines getContextPath()?

And probably some other methods.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Why not just redirect to the correct URI?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Modify request URI
It's not a secret anymore!