Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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: 66607
161
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!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!