Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java HttpServletRequest getquerystring

In my servlet, req.getQueryString() returns null when an ajax request is sent to it. Is this because req.getQueryString() only works for GET and not POST?

public void doPost(HttpServletRequest req, HttpServletResponse resp) 
        throws ServletException, IOException {
req.getQueryString();
}
like image 610
user2760273 Avatar asked Dec 29 '25 16:12

user2760273


1 Answers

The easiest way to get hold of request parameters is to use request.getParameter(). This works for both GET and POST requests.

POST requests typically carry their parameters within the request body, which is why the request.getQueryString() method returns null.

like image 174
rcgeorge23 Avatar answered Dec 31 '25 05:12

rcgeorge23