• 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 matching doubt

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

1. In directory match was is necessary to have the end slash also.

eg:



is this servlet match with the following request as directory match?
http://localhost/Test/abc (no end slash like /abc/)


2.It was said that if a request match more than one url-pattern container will choose the longest mapping also it was said container will first look for exact match , directory match and then extension map. so its kind of contradictory know? since the exactly match is the longest this wouldnt be a problem? but what if we choose both exact and directory match have the same length.
eg:
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this case the exact match will always win.

As for the slash, a mapping of /dir/* and a request of http://localhost:8080/PROJECT_NAME/dir will also map to the corresponding servlet.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ive found this article also it says if that slash not there it will need a exact macth..


That would be an unmatched pattern since the * would not be a wildcard, but must be an exact match



reference:
https://coderanch.com/t/422371/Servlets/java/HttpServletRequest-getRequestDispatcher-behaving-strangely
 
reply
    Bookmark Topic Watch Topic
  • New Topic