Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get RequestMethod of ServletRequest?

I have ServletRequest, which client machine sent. How to know which one it is: GET POST UPDATE or DELETE?

like image 427
annoirq Avatar asked Oct 22 '15 13:10

annoirq


People also ask

Can we get request body from HttpServletRequest?

To read the HTTP request body from HttpServletRequest object, you can use the following code snippet. You can then convert the JSON string from the request body into an object of any class. Let's assume that we need to convert the JSON object from the request body into an object of the following class.

What is ServletRequest and ServletResponse?

ServletRequest and ServletResponse are two interfaces that serve as the backbone of servlet technology implementation. They belong to the javax. servlet package. Signature: public interface ServletRequest. Blueprint of an object to provide client request information to a servlet.

What is Httpservlet request?

The HttpServletRequest provides methods for accessing parameters of a request. The type of the request determines where the parameters come from. In most implementations, a GET request takes the parameters from the query string, while a POST request takes the parameters from the posted arguments.


1 Answers

HttpServletRequest contains getMethod() which returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT

like image 193
Shriram Avatar answered Oct 02 '22 13:10

Shriram