• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Filters - A couple of questions

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it
reply
    Bookmark Topic Watch Topic
  • New Topic