Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

servlet-mapping question

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm confused on what can be assigned to a <url-pattern> inside <servlet-mapping> element. Are the following correct?
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>*</url-patteren>
</servlet-mapping>
</servlet-mapping>
<servlet-name>TestServlet2</servlet-name>
</url-pattern>/</url-patteren>
</servlet-mapping>
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, both are correct. You can use anything starting with a "/", witch refers to the root of application(webapps/yourapplication).
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think just a * for <url-pattern> is not enough.
The servlet spec does not say anything specifically for just "*" values.
I tested with Tomcat. It gives 404 error even for index.html under the context root.
Can others comment on it?
Thanks!
Regards,
Maha Anna
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seconding Maha Anna here. "/" is the default servlet, "*" is invalid.
- Peter
 
I didn't say it. I'm just telling you what this tiny ad said.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic