• 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

Servlet Mapping vs Static resource

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
I have a static resource which is defined as webapps/myApp/home/index.html and I have defined mapping of a servlet in the same web app with URL pattern as "/home/index.html".
e.g. <servlet-mapping>
<servlet-name>xyz</servlet-name>
<url-pattern>/home/index.html</url-pattern>
</servlet-mapping>
If a URL http://host ort/myApp/home/index.html is entered through browser, will it get the static resource index.html or invoke the servlet xyz?

thanks,
Dev
 
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
Have you tried it?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it will invoke the servet xyz
 
Ben Souther
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
Yep.
That the container will choose the servlet-mapping over the static file is the basis for a common work-around for creating a "Welcome File" servlet.

Some containers (older versions of Tomcat) wouldn't allow you to use a servlet as the welcome file. By creating a mapping for, say.. "index.html", putting a blank index.html page on the server and then setting "index.html" as the welcome file, you're able to use a servlet as your intro page.
 
reply
    Bookmark Topic Watch Topic
  • New Topic