A default servlet mapping has a mapping of only the / character. In competitive application servers,
a call to the javax.servlet.http.HttpServletRequest.getServletPath method for a default servlet mapping
returns the value of the request URI minus the context path, and a call to the
javax.servlet.http.HttpServletRequest.getPathInfo method returns null.
In WebSphere traditional, a call to getServletPath for a default servlet mapping will return an empty string,
and a call to the getPathInfo method returns the / character.
Similarly, if you are migrating to Liberty and using the Servlet 3.0 or 3.1 feature implementations, a call to getServletPath for a default servlet mapping will return an empty string,
and a call to the getPathInfo method returns the / character.
For example, consider the following code:
In competitive application servers, this code will have the following output:
However, in WebSphere traditional and Liberty with Servlet 3.0 or 3.1, the code will have the following output:
If you are migrating to WebSphere Liberty and using the Servlet 3.0 or 3.1 implementations, add the <webContainer servletPathForDefaultMapping="true"/>
element to the server.xml configuration file. Adding this element will result in the
getServletPath and getPathInfo methods behaving as they do in competitive application servers.
If you are using the Servlet 4.0 implementation, no change is needed. getServletPath
and getPathInfo in the Servlet 4.0 implementation behave the same as in the competitive application servers.
If you are migrating to WebSphere traditional, set the WebContainer
com.ibm.ws.webcontainer.EnableDefaultServletRequestPathElements property to true.
Setting this property will result in the getServletPath and getPathInfo methods
behaving as they do in competitive application servers.
For additional information, see: