This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

changing http get request to post request

 
Ranch Hand
Posts: 110
Firefox Browser MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am facing this problem in my application. I have two servlets, servlet A and servlet B. Servlet A receives a GET request , process the request and forwards it to servlet B. Servlet B handles POST requests only. I shouldn't change the code of Servlet B.
Is it possible to change the request type from GET to POST in servlet A or Is there any way to create a new POST request from servlet A to servlet B.
Any information on this is really useful.

Thanks,
Sai
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method property of HttpServletRequest is read only.

Adding a doGet method to servlet B would be the easiest thing to do but if that's not possible, you could wrap the request, providing your own getMethod method. The servlet spec provides the HttpServletRequestWrapper to take some of the grunt work out of this.
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

I was looking for solution for a similar scenario. Thanks for your post.

Your idea works pretty good.
 
    Bookmark Topic Watch Topic
  • New Topic