Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Filtering Question  RSS feed

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!