Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard path for servlet?

Having an @WebServlet(urlPatterns = "/myServlet/"). If the user goes to myapp/myServlet/other, I still want my servlet to catch. So to say, wildcard anything on after the servlet path. How could I do this?

like image 330
membersound Avatar asked Oct 19 '12 11:10

membersound


1 Answers

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:

  • Servlet and path parameters like /xyz/{value}/test, how to map in web.xml?
like image 51
BalusC Avatar answered Sep 20 '22 15:09

BalusC