This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to change the HTTP method (GET or POST)  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

In HttpServletResponse we have setHeader method for example response.setHeader("Content-Language", "es") .Is it possible to change HttpMethod like GET to POST using setHeader?

Thanks & Regards,

Siddarth
 
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An HTTP response has no method associated with it - only an HTTP request does.
 
Ranch Hand
Posts: 93
IntelliJ IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thamarai kannan wrote:Hi friends,

In HttpServletResponse we have setHeader method for example response.setHeader("Content-Language", "es") .Is it possible to change HttpMethod like GET to POST using setHeader?

Thanks & Regards,

Siddarth




You need to do a new request in order to define the method used. When you have a new URL object to do the request, you'll be able to change the method with setRequestMethod.


URL url = new URL(urlString.toString());
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(HttpMethod.GET.name());
 
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question isn't clear, How do you expect to change the HTTP method with the use of the HttpServletResponse? Even though you can't change the HTTP method with HttpServletRequest object? Because, it's out of concept to HttpServletRequest object!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!