How come request.getPathInfo() in service method returns null?

@Vivien is correct. You'd like to use HttpServletRequest#getServletPath() instead (sorry, I overlooked that bit while writing the answer which you undoubtely was reading, I've updated the answer).

To clarify: getPathInfo() does not include servlet path as definied in web.xml (only the path thereafter) and getServletPath() basically returns only the servlet path as definied in web.xml (and thus not the path thereafter). If the url pattern contains a wildcard, particularly that part is included.


According to the Javadoc:

Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.

You don't have any path info when using a prefixed mapping (*.do, in your case).