Yes you can.
You need to access the "Location" header of the response
( See:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 )
But it is not that straightforward in servlets since there are no response.getHeader methods available!! ( I dont know why it is so. )
Thankfully, there is a solution using ResponseWrapper. Write your own response wrapper and override the setHeader method. In the over-ridden setHeader catch the location value and store it in a wrapper instance variable for access from filter.
Code would be something like this:
public class LocationFinderWrapper extends HttpServletResponseWrapper {
private String location;
//write getter and setter
public void setHeader(String name,String value){
if( "location".equalsIgnoreCase(name) )
setLocation(value);
super.setHeader(name,value);//dont forget this!
}
}
Instantiate this wrapper around your original response object and then when you call chain.doFilter pass the wrapper object. This needs be done in the doFilter method of your filter.