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

How can I change a GET request to POST ?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The initial servlet gets a GET request.
It has to forward it to another servlet. Is it possible for the intial servlet to forward to the another servlet using a POST method ?
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiiii Celina,

i donno if there is any way to do that.. but u can achieve this by doing one thing.. that is..
write both the methods (i.e. doGet and doPost) in your servlets and in doGet() you can call doPost like following.

i hope by this ur problem will be solved... do let me know if still in doubt.
Thanks
Amit
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you cannot. Why do you feel the need to do this?
bear
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can directly forward the request to another servlet. The servlet to which you direct the request should contain the doPost method.it is as simple as this. kinldy let me know if there are any corrections.
good luck.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that a request has a method already, in the very first header. Simply forwarding a GET can't change it into a POST. RFC2616 lays out the rules for HTTP requests - a Yahoo search will find you a copy.
Your servlet could create a new POST request, send it, and then interpret the result to create a response, and there are other approaches. For example, you might be able to create a HttpServletRequestWrapper to be forwarded (but I have not tried this).
Bill
[ November 03, 2003: Message edited by: William Brogden ]
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic