user471011
user471011

Reputation: 7374

Servlet. Specification of Mappings?

Based on Java Servlet Specification Version 3.0:

In the Web application deployment descriptor, the following syntax is used to define mappings:

A string beginning with a '/' character and ending with '/*' suffix is used for path mapping.

A string beginning with '*.' prefix is used as an extension mapping.

A string containing only the '/' character indicates the "default" servlet of the application.

All other strings are used for exact matches only.

so, I have next questions:

  1. How I can process this URL pattern: "/foo/bar/*.jsp"?

  2. What principal difference between '/*' and '/'?

Upvotes: 0

Views: 135

Answers (1)

axtavt
axtavt

Reputation: 242686

  1. Use less restrictive pattern (for example, /foo/bar/*) and apply additional restrictions programmatically.

  2. / handles request only if its URL doesn't match any other mapping, whereas /* follows normal mapping precendence rules.
    For example, if you map front controller of your application as /* you won't be able to render JSP pages, because /* takes precendence over built-in JSP servlet mapped to *.jsp.

Upvotes: 1

Related Questions