R
R
ruslanys2014-04-04 13:32:20
Java
ruslanys, 2014-04-04 13:32:20

J2EE - what's the difference in servlet mapping URL regexes?

What's the difference between

<servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
</servlet-mapping>

and
<servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
</servlet-mapping>

?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Lopatin, 2014-04-04
@lorus

Both options designate a default servlet. The difference is what data the HttpServletRequest will contain.
In the first case, HttpServletRequest.getServletPath() will return the path to the servlet, and HttpServletRequest.getPathInfo() will return null.
In the second case, getServletPath() will be empty and getPathInfo() will contain the path to the resource.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question