The below spring controller forwards the request to a static JSP path using RequestDispatcher.forward()
RequestDispatcher rs = getServletContext().getRequestDispatcher("/security/html/blah.jsp");
try {
rs.forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
The code is working perfectly fine in local machines. But when I deploy it on cloud servers, I get a stacktrace stating
javax.servlet.ServletException: Requested URI [//security/html/blah.jsp] does not match Resource path pattern
For some reason, a extra slash is added in the resource path, which is causing the issue. If I enter the URL (by removing the extra slash) manually in the address bar, it works.
Since it is a internal forward, I am not even sure whether an extra slash is added in the local machines or not, because the below URL (with two slashes in the path) works locally but not working on cloud servers
IP:port/context//security/html/blah.jsp
I saw a similar issue on the below link (unfortunately, without a solution)