You shouldn't have to change anything in Nginx or Tomcat config. What you could do is to create a servlet that will intercept the requests and extract the {{random_string}} before forwarding to the JSP. Here are the basic steps:
1) Create a servlet with a URL pattern of /*
so that all requests go to it.
2) In the servlet's doGet()
method, use request.getPathInfo()
to retrieve the URL path and parse it to extract the {{random_string}}.
3) Use request.setAttribute()
to set attributes for the data you want to display in the JSP page.
4) Forward the request to the JSP using a RequestDispatcher, e.g.:
RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
dispatcher.forward(request, response);
5) In the JSP, use the request attributes that you have set in step 3 to display the content.