• 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

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

In the PetStore application, web.xml contains the following mappings:

.... and:


If I navigate in my browser to http://localhost:8087/petstore/faces/catalog.jsp?catid=Cats#feline01,1,
what servlet mappings will be performed: both the FacesServlet (because of the /faces) and the ControllerServlet (because of /catalog)
or just the best match, which is ControllerServlet ?

Also, when I debug the ControllerServlet, I see in the debugger that getRequestURI() is /petstore/catalog and getServletPath() is /catalog. Where is /faces then ?

Thank you,
Best regards,
Sorin
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sorin Alexandru wrote:



I means that every request with URL matching "/faces/*" will be directed to this servlet. There's no "/faces" folder. It's just an expression to match by URLs.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no ambiguity there. The "/" at the beginning of the URL pattern means "root", so a "/faces/catalog/anything" will always route to the Faces Servlet and a "/catalog/faces/anything" will always route to the catalog servlet.

A lot of people don't understand the difference between resources (files and folders) and URLs, because they look so similar and because the default action is to take a URL and convert it into a resource path. But the difference is critical. web.xml does its matching on URLs, not resource paths.
 
reply
    Bookmark Topic Watch Topic
  • New Topic