This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
If you are modifying an existing request, the servlet API provides the HttpServletRequestWrapper class to accomplsh this since you can't modify an existing request directly. You create a custom wrapper that watches for getParameter calls specifying the parameters of interest. If you are creating a new request, just implement the HttpServletRequest interface in your custom class. Bill
Hi, I am curious about this... Where we can modify a request using that request wrapper? In a filter class or servlet class?
Correct me if my understanding is wrong thanks daniel
Joined: Jul 09, 2001
Hello, I don't want to modify the query string. I want to modify the HTTP header.
Thanks in advance.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Basically you use a Filter to substitute your custom request wrapper object for the original request. Your custom wrapper will be what the servlet sees so every request for a header OR for a parameter OR for an input stream will go to your filter first. Take a look at the javax.servlet.http.HttpServletRequestWrapper class JavaDocs to see how convenient the designers have made this capability. Bill