Wildcard path for servlet?

You can use * as prefix or suffix wildcard. In your case, you can use /myServlet/* for a folder mapping.

@WebServlet("/myServlet/*")

The path info (the part after the mapping in the URL) is in the servlet by the way available as:

String pathInfo = request.getPathInfo();

This would in case of myapp/myServlet/other return /other.

See also:

Leave a Comment