how do i chain up servlet filters?

A

Angus Parvis

Hi,

I am developing a web-application using Tomcat 5. Most of the user's
requests invoke servlet filters before the request is passed to the
servlet itself.

What I want to do is to chain up several filters. For example when the
users requests /MyServlet the filter-chain should be like this:

LocalizationFilter -> AuthenticationFilter -> /MyServlet

There are more filters involved in this chain, but I don't want to make
the question too complicated.

Furthermore not every filter should be invoked at every request. There
are some servlets, that don't require authentication. These servlets are
located in a directory called /public, so every call to
/public/MyPublicServlet should invoke this chain:

LocalizationFilter -> /MyPublicServlet

I'm new to servlet filters and couldn't find any help in the
documentation of Tomcat or Java Servlets. If you know some good docs or
have some Tomcat-configs to solve this problem, please post them.

Thank you very much for your help.

Greetings,

Angus
 
C

Cid

I'm new to servlet filters and couldn't find any help in the
documentation of Tomcat or Java Servlets. If you know some good docs or
have some Tomcat-configs to solve this problem, please post them.

See the java web services tutorial
http://java.sun.com/webservices/docs/1.3/tutorial/doc/index.html

Chapter 15: Filtering Requests and Responses

You'll set up a filter-mapping elements in web.xml to specify the
filter chain for each servlet or groups of servlets matching url
pattern, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top