[Logo]
Forums Register Login
How to change the HTTP method (GET or POST)
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
No.
An HTTP response has no method associated with it - only an HTTP request does.
 
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());
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!
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 18, 2017 05:16:12.