0

I'm using a Servlet accessible via POST request, but I've seen that parameters in POST, can be set either thanks to header parameters but also in a GET format way (/MyServlet?param1=123&param2=456) and I would need to detect it on my Servlet.

I tried to retrieve the request by using

request.getRequestURI()

but I cannot see the parameters in that case... Do you know how can I retrieve the full path of the request in a GET parameter way ?

tiamat
  • 879
  • 2
  • 12
  • 35
  • so, that's right, the question has been answered already, I just need to check if request.getQueryString() != null to distinguish the parameter type. – tiamat May 24 '22 at 05:47

1 Answers1

-1

getParameter() returns http request parameters. Those passed from the client to the server. For example http://example.com/servlet?parameter=1. Can only return String.

Comrade Anas
  • 11
  • 1
  • 6
  • 1
    yes I know but how can I distinguish a parameter passed by Content-Type (usual way for POST commands) with the ones passed by example.com/servlet?param1=1&param2=2 (usual way for GET commands) ? – tiamat May 23 '22 at 15:33