Is it possible to forward a request changing the request method?

I'm working thorough a gateway, which allows only GET requests, whilst REST endpoints behind it are able to accept the wide range of methods (POST, PUT, DELETE, OPTIONS). Therefore, I'm trying to pass the request method as a parameter, having a filter, which forwards the request with a correct method. From what I can see in the specification, it's only allowed to forward the request w/o any modifications:

request.getRequestDispatcher(route).forward(request, response)

Are there any workarounds?

NOTE: Redirect is not an option for me.


If you have a single Rest servlet that handles the restful services (and this is usually the case), you can extend it and override the service method. There you can invoke doPost(..), doPut(..), etc. depending on the parameter you want. The default implementation of HttpServlet uses request.getMethod().

Another thing you can do (less preferable) is to have your Filter fire a new request to the endpoint, using URL.openConnection (or apache commons http components), and stream the result of that internal request back to the client. There you can specify the request method.

Anyway, I think you should try to overcome the limitation of your gateway, because it puts you in a really awkward situation.

Need Your Help

Microsoft Reporting: Check if a certain value exist reporting-services

Using Microsoft Reporting Services, with local processing mode. Loading data sources and everything works nicely. What I would like, is to, in the the report definition, check if a certain value e...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.