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();
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With