Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url matching doubt

 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • 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:
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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: 348
  • Mark post as helpful
  • send pies
  • 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:
http://www.coderanch.com/t/422371/Servlets/java/HttpServletRequest-getRequestDispatcher-behaving-strangely
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic