aspose file tools*
The moose likes Servlets and the fly likes Using filter, is it possible to insert name/value pair into header? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using filter, is it possible to insert name/value pair into header?" Watch "Using filter, is it possible to insert name/value pair into header?" New topic
Author

Using filter, is it possible to insert name/value pair into header?

Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
I am looking to put togeather a filter which would simulate the siteminder web agent. This web agent puts two variables into the header,
"sm-userid" & "sm-userdomain"; I would like to simulate this behavior but have not found any documentatio on adding header values. Can it be done?
Regards,
Joshua
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hello Joshua,
When you say "adding header values" do you mean "adding HTTP response hearder values"? If yes, then you can use the HttpServletResponse interface methods (addHeader, addIntHeader, addDataHeader) to modify or add headers to the response stream.
And, yes this can be done in a Filter becuase the response and request objectives are passed to the doFilter method.
Regards,
Bryan
Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
Bryan,
Siteminder adds header values to the request. I would like to simulate this for our development environment. Unfortunately adding headers to the response will not help me here.
I have another filter which is looking for the siteminder information using request.getHeader("foo").
Any ideas?
Regards,
Joshua
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
I believe you can extend HttpServletRequestWrapper to create a class that will "wrap" a request to add your special functionality. Presumably you would then forward the wrapped request instead of the original one.
Have not tried this myself.
Bill
 
Don't get me started about those stupid light bulbs.
 
subject: Using filter, is it possible to insert name/value pair into header?