Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Filters - A couple of questions

 
Andreas Markitanis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I am pretty new to servlet filters and just want to ask a couple of questions

1. Can you have one filter with two url-patterns tags in web.xml (for example one for *.jsp and one for /servlet/*)?

In other words, is the following piece of code allowed in the deployment descriptor (web.xml)?



2. If I use a Filter to intercept all requests (your url-pattern is /* ) which will redirect the user to index.jsp if there is no user attribute stored in the session I get the following behaviour

- accessing a restricted page when there is no session redirects the user to the index page
- accessing a restricted servlet will produce an IllegalStateException.

Does that mean I have to create two different filters, one to cater for jsp, and one for servlets?

The following is a snippet of code which fails to exhibit the behaviour stated in 2.


Any help is much appreciated.


Thanks
andreas
 
Andreas Markitanis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following my post above,

Should the chain.doFilter(request, response) method be called only if access is granted to propagate the request and response to the next filter in the chain?

If so, isn't my problem fixed with the following snippet of code?

 
sanjeev tuli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic