I want to do authentication in a ServletFilter. I mapped the filter to /* in the deployment descriptor. In the doFilter method, I say, if you are not logged in, then you are forwarded to the login page. The problem with this is that the images that I am trying to display on my login.jsp page will no longer show up because the filter will not let the requests for the images get through. I inserted some code into the doFilter method that said if "gif" appears in the request, then call filterChain.doFilter(request, response) but if not, then check for an existing session. The images will display properly when I do this but I know that doing so is not the correct way to write a ServletFilter. Can anyone give me some advice on how to fix this problem? Thanks a lot.
Maybe you should think about putting your 'protected' pages versus 'login' page versus 'images' into a folder structure, and only apply the filter to 'protected' ones. / -- login page /images -- all your images /protected -- all your pages which require login first
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
a bit of art, as a gift, the permaculture playing cards