How to set custom HTTP REQUEST HEADER
I need to set a custom header within my JSP based on value I retrieve from a cookie. This cookie is set by a Single Sign On (SSO) service but all it does is set a cookie once the user is authenticated and then it redirects back to a JSP (mine) or whatever URL I supply. It doesn't set anything in the HTTP HEADER so I have to do this somehow. It must be the the HEADER because that is the only way for the Trusted Authentication Service (TAS) URL that handles login to retrieve this value.
I thought I could simply use the response.setHeader method within my JSP and then redirect to the necessary URL for login. I though开发者_运维问答t this would mean that this custom header would now be part of the REQUEST. It sounds like this can't be done however. I've been told that I could create a Filter that wraps the HttpServletRequest in my own subclass of HttpServletRequestWrapper. Override the getHeader() method to return my custom header, or return the regular header. I really don't know what this means or how I can do this from my JSP.
Any help is GREATLY appreciated!
I think they're are good tutorial on the net on how to create a servlet filter.
Basically a filter will 'intercept' the request and do something special with it (i.e. call a special class)
I think you could do your redirect from that class.
Just saw this to get you started :
http://viralpatel.net/blogs/2009/01/tutorial-java-servlet-filter-example-using-eclipse-apache-tomcat.html
精彩评论