Is it possible to get the raw HTTP Request from the HttpServletRequest object? I want to see the raw request as a String if at all possible.
I need to get the full text of the request, in this case it's a POST request, so the URL doesn't help. It's also part of a multi-part form, so I can't just call the "getParameterNames()" or "getParameterValues()".
Thank you,
String getRequestURI() -Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. java. lang. StringBuffer getRequestURL() -Reconstructs the URL the client used to make the request.
ServletInputStream. getInputStream() Retrieves the body of the request as binary data using a ServletInputStream . java.lang.String.
public HttpServletRequestWrapper(HttpServletRequest request) Constructs a request object wrapping the given request. Throws: java.lang.IllegalArgumentException - if the request is null.
getHeader. java.lang.String getHeader(java.lang.String name) Returns the value of the specified request header as a String . If the request did not include a header of the specified name, this method returns null . If there are multiple headers with the same name, this method returns the first head in the request.
You can read the raw HTTP request by doing:
ServletInputStream in = request.getInputStream();
and then use the regular read
methods of the InputStream.
Hope that helps.
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