Timeline for How to modify HttpServletRequest body in java?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 13, 2021 at 9:38 | comment | added | Bogdan |
1) that's exactly what I'm saying in the answer. You wrap the original request into your own version with the help of HttpServletRequestWrapper . In your version you change what you want different and let everything else go through to the original request object you wrapped. 2) You will probably need to implement the getInputStream method in your wrapper to return an InputStream constructed from your String (maybe some other methods from the wrapper too, depending on what else you need). You then send the wrapper request to your servlet in the chain, not the original request.
|
|
Jan 12, 2021 at 21:17 | comment | added | obayral | Thanks for the answer! It gave me a better insight. I do have 2 follow up questions though. 1) I can't change the request, but can't I wrap the request into a form that I want? 2) I can do a classical parsing and String manipulations(this was my 1st approach also), however how can I pass this String to HttpRequest to be processed by the Servlet? Thanks. | |
Jan 12, 2021 at 21:14 | vote | accept | obayral | ||
Jan 12, 2021 at 21:01 | history | edited | Bogdan | CC BY-SA 4.0 |
added 279 characters in body
|
Jan 12, 2021 at 20:50 | history | answered | Bogdan | CC BY-SA 4.0 |