*
The moose likes Servlets and the fly likes HttpServletRequestWrapper won't return any getParamter value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletRequestWrapper won Watch "HttpServletRequestWrapper won New topic
Author

HttpServletRequestWrapper won't return any getParamter value

Gihan Anuruddha
Greenhorn

Joined: Sep 09, 2013
Posts: 2
I want to log each request with request body to a file. So I used web filter and HttpServletRequestWrapper to achieve this task. But when I do any parameter request I'm not getting any value always. As example if I do req.getParamter("usrename") inside the servlet or even within the filter I'm not getting any value. Here are the code snippets I used in both filter and extended HttpServletRequestWrapper class. Can anyone tell me what is the wrong here. Really appreciate you help ?

Filter


My extended HttpServletRequestWrapper class

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
These requests where you are unable to get the parameter - are they GET or POST requests?

Recall that for a POST, the parameters are in the body of the request.

Bill

Gihan Anuruddha
Greenhorn

Joined: Sep 09, 2013
Posts: 2
Those are POST requests. Actually I realize that the wrapped http request object called when I invoke getParamter method. At that time I already used getInputStream method and there is no stream to return any parameter value. So now as a solution I start to overwrite all getParameter methods in side my custom HttpServletRequestWrapper class.
 
Don't get me started about those stupid light bulbs.
 
subject: HttpServletRequestWrapper won't return any getParamter value
 
Similar Threads
problem while reading multipart/form-data
Post parameters are becoming null (at random)
OK to read the request body within a filter?
Intercepting XML using Servlet Filter
Inner class is not getting instantiated in java 5 and the same works fine in java 6