• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I change a GET request to POST ?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic