servlet filters - multiple url-mappings?

B

benh_usenet

I would like to be able to do something like the following in order to
get my welcome page and servlet pages to run though a filter, but
nothing that's in other directories.
From web.xml...

<filter-mapping>
<filter-name>myFilterName</filter-name>
<url-pattern>/servlet/*</url-pattern> <!-- run filter on stuff in
servlet dir -->
<url-pattern>/</url-pattern> <!-- also apply this filter to
the root document -->
</filter-mapping>

I did try the following as well, but had no luck.

<filter-mapping>
<filter-name>myFilterName</filter-name>
<url-pattern>/servlet/*</url-pattern> <!-- run filter on stuff in
servlet dir -->
</filter-mapping>
<filter-mapping>
<filter-name>myFilterName</filter-name>
<url-pattern>/</url-pattern> <!-- also apply this filter to
the root document -->
</filter-mapping>


Does anyone have any suggestions as to how this might be actually
achieved, since the dtd won't allow multiple url-mapping elements?

I need to be able to do this because the root document in my
application actually forwards to a proper struts action in the servlet
directory, so I want to allow the filter to work on that, and stuff in
the servlet directory, but not on other servlets.

Thanks

-Ben
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top