public static void setLocation ( HttpServletRequest request , HttpServletResponse response , String location ) { if ( request . getAttribute ( IS_INCLUDED_REQUEST_ATTRIBUTE_NAME ) == null ) { // Not included, setHeader directly response . setHeader ( "Location" , location ) ; } else { // Is included, set attribute so top level tag can perform actual setHeader call request . setAttribute ( LOCATION_REQUEST_ATTRIBUTE_NAME , location ) ; } }
Sets a Location header . When not in an included page calls setHeader directly . When inside of an include will set request attribute so outermost include can call setHeader .