This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 12761
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using filter, is it possible to insert name/value pair into header?
 
Similar Threads
Web Browser
Finding the client OS
dynamic link for internet and intranet
Adding http headers
Checking Browsers...