Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

filter configuration in web.xml  RSS feed

 
andrew ronchi
Ranch Hand
Posts: 50
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can there be <url-pattern> and <servlet-name> elements present in <filter-mapping> element together in web.xml??
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can see from the web.xml dtd, the syntax is:
<!ELEMENT filter-mapping (filter-name, (url-pattern | servlet-name))>

This means you have url-pattern OR servlet-name. However, servlets have their own mapping you can configure with the servlet-mapping tag.
 
andrew ronchi
Ranch Hand
Posts: 50
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Jeanne , as per servlet specification 3.0 there can be multiple <url-pattern> and <servlet-name> elements in <filter-mapping>.

Internally container creates multiple <filter-mapping> elements with each <url-pattern> and <servlet-name> sub elements.

Thank you for your reply.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 reasons not to trust the DTD.

1. It's obsolete. All modern-day Java XML specs are in xml schemas

2. It's not definitive. The XML schema more precisely defines what is and isn't allowed.

DTDs are a lot easier to read, though!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!