Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

changing http get request to post request

 
Venkata Kumar
Ranch Hand
Posts: 110
Firefox Browser Java MySQL Database
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 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.
 
Ashok Kumar Babu
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic