Tony R
Tony R

Reputation: 11524

How to maintain request.getReader() with a filter?

After I added a filter to my app, I am not able to read anything from HttpServletRequest.getReader() in my controllers.

I am calling request.getParameter() a few times, but other than that my filter doesn't do much.

Upvotes: 0

Views: 363

Answers (1)

Tony R
Tony R

Reputation: 11524

Okay I just thought through the problem and realized that for POST requests, calling getParameter() can cause a problem because POST params would typically be in the request body. The input stream will indeed be opened implicitly by the filter.

In my filter (and in my case) I need to check:

if (((HttpServletRequest) request).getMethod().equals("GET")) {...}

Upvotes: 1

Related Questions