This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
yes right. by the browser. What i'm trying to do is simulate what Siteminder does during preauthentication. It adds a header called SM_USER to the browser generated headers. Our project is not setup with a real siteminder yet so we need to manually add SM_USER to the headers so development could continue.
There is a Firefox plugin called Modify Headers that allows you to add headers. Unfortunately i can't find a similar tool for Internet Explorer. And we have to test the pages in IE too. I'm wondering if this can be done by using the URLConnection class?
I think the best tool for inserting a request header before a servlet processes the request would be a servlet filter.
Joined: Mar 21, 2006
yes a filter is a good idea. I see you can set the values of existing headers by overriding the getHeaders(string) method of the HttpServletRequestWrapper. But what if want to add a new header name with a specific header value?
Instead of playing with headers you can write filter in such a way that if SM_USER is not available in the Request header use some default value as a user id and process the request.
1) Your code after the filter should not rely on the SM_USER if you want to follow this approach.
2) You can initialize a new variable that represents SM_USER and put it in the request scope and use that as a user identifier.
3) In servlet filter try to read SM_USER and if it is not present then initialize the request attribute with some default value.
This way you will not have to use a browser specific solution.
Hope this helps.