0

I have some doubts in understanding how the value in <url-pattern> is interpreted to match in either <servlet-mapping> or <filter-mapping>. Basically the doubts comes in how * is interpreted.

Let us assume that I deployed a web-application(.war) with context root /firstweb.

Consider the following <url-pattern> defined in web.xml

(1) <url-pattern> /* </url-pattern>
(2) <url-pattern> /test/abc </url-pattern>
(3) <url-pattern> /test/abc/* </url-pattern>
(4) <url-pattern> /*/abc </url-pattern>

What I am aware of is that "*" matches any string / text. With this as basis, I have some doubts.

Q1) For case (1) viz /* would it match anything? If so, would this match /test, /text/abc, /test/abc etc. when it is in the url?

Q2) Now for case (2) viz /test/abc would it match when url is exactly /test/abc? what about /* because as I believe * means any text. Won't this make it ambiguous matching pattern?

Q3) Also, I believe all these url are w.r.t to context-root i.e. all urls are like: /firstweb/xxx' ,/firstweb/test/abc,/firstweb/`.

Any answers in simple words to clear this doubt is highly appreciated.

Edit

Did some more research, the following links are helpful in understanding the how to interpret <url-pattern>

a) what if url pattern matches multiple servlets?

b) http://docs.roguewave.com/hydraexpress/3.5.0/html/rwsfservletug/4-3.html

Community
  • 1
  • 1
CuriousMind
  • 8,301
  • 22
  • 65
  • 134
  • Asking one question per Question makes it easier to find duplicates. Each of those questions are already individually asked before. Hint: browse through "Related" list on right hand side. – BalusC Apr 16 '16 at 07:27
  • @BalusC: I agree, however sometimes questions are interrelated that it is imperative to put them as a single place. I looked at the links, my doubts are still not clear. If you can answer for (1) and (2) would be great. Personally I checked in tomcat for * and /test/abc and it seems * can take any input urls /test /text /test/abc/xyz ... – CuriousMind Apr 16 '16 at 15:46
  • 1
    1) is answered in http://stackoverflow.com/q/4140448 2) is indirectly answered by answer to 1). – BalusC Apr 16 '16 at 15:50
  • Thanks for this link, had seen this.. let me check this again.. Thanks lots! – CuriousMind Apr 16 '16 at 17:35

0 Answers0