• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using filter with more than one servlet  RSS feed

 
aman thind
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please tell me how to separate the url patterns in web.xml if i want to use same filter with more than one servlet?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"alacrious",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
url pattern should be '/*'.

an example follows:
http://jamonapi.sourceforge.net/#ServletFilter
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use wild cards in url-pattern.
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<filter>
<filter-name>FilterC</filter-name>
<filter-class>TestFilter</filter-class>
</filter>

<!-- associate FilterC to a request matching /red/* -->
<filter-mapping>
<filter-name>FilterC</filter-name>
<url-pattern>/red/*</url-pattern>
</filter-mapping>

Now any request with /red/ as a prefix will invoke FilterC
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!