• 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

url pattern in web.xml

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to specify 2 url patterns for that same servlet, but not able to do so.
<servlet-mapping>
<servlet-name>HtmlFilter</servlet-name>
<url-pattern>/html/*</url-pattern>
<url-pattern>/HtmlFilter</url-pattern>
</servlet-mapping>

But, it is taking request only for /HtmlFilter, but not for /html/*.
Do i need to give two servlet-mapping and two declarations for servlet using <servlet>.
Please tell.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to declare two servlet-mapping tags i.e.
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, why is your servlet named "filter" but it is not a Filter?
 
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, you can provide as many as mapping you want for a servlet
mapping can be done in single mapping block like this


Vijay (SCJP)
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I specified many url-patterns, but it took only one.When i wrote multiple servlet-mappings ,then it worked. Seems like we can not write multiple url-pattern in same servlet-mapping
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vijay dadhwal:
yes, you can provide as many as mapping you want for a servlet
mapping can be done in single mapping block like this


Vijay (SCJP)



This is true, but only in Servlet Spec 2.5 and up.
Look at SRV.S.19 (Changes from Servlet 2.4):


SRV.19.0.3 Multiple Occurrences of Servlet Mappings
Previous versions of the servlet schema allows only a single url-pattern or servlet
name per servlet mapping. For servlets mapped to multiple URLs this results in
needless repetition of whole mapping clauses.
The deployment descriptor servlet-mappingType was updated to:





So..
If you're writing for containers that don't support the 2.5 spec, you'll need to create multiple servlet-mapping entries.
[ December 16, 2008: Message edited by: Ben Souther ]
 
vijay dadhwal
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for information

Regards
vijay
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic