public static HttpServletResponse getHttpServletResponse ( Object response ) { // unwrap the response until we find a HttpServletResponse while ( response != null ) { if ( response instanceof HttpServletResponse ) { // found return ( HttpServletResponse ) response ; } if ( response instanceof ServletResponseWrapper ) { // unwrap response = ( ( ServletResponseWrapper ) response ) . getResponse ( ) ; } // no more possibilities to find a HttpServletResponse break ; } return null ; // not found }
Trys to obtain a HttpServletResponse from the Response . Note that this method also trys to unwrap any ServletResponseWrapper in order to retrieve a valid HttpServletResponse .