| Author |
Setting HttpServletRequest headers
|
Thomas Mcfarrow
Ranch Hand
Joined: Jul 09, 2001
Posts: 137
|
|
Hello, I need to make a code stub for some SSO software that my company uses. I wan't to mimick its behavior by setting HttpServletRequest headers and forwarding it on. How could I set request headers? Thanks.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Fisher Daniel
Ranch Hand
Joined: Sep 14, 2001
Posts: 582
|
|
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
|
 |
Thomas Mcfarrow
Ranch Hand
Joined: Jul 09, 2001
Posts: 137
|
|
Hello, I don't want to modify the query string. I want to modify the HTTP header. Thanks in advance.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
|
|
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
|
 |
 |
|
|
subject: Setting HttpServletRequest headers
|
|
|