I am fixing some old defects and as part of one defect, I need to make sure that some requests are being only POST to the JSP page instead of a GET request. The application have
Two solutions:
Add a with an empty on an of *.jsp and of GET which will block GET requests on JSP files to everyone (as suggested by McDowell):
Restrict GET requests on JSP files
JSP files
*.jsp
GET
Create a Filter which listens on an of *.jsp and does basically the following in the doFilter() method.
if (((HttpServletRequest) request).getMethod().equals("GET")) {
((HttpServletResponse) response).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
} else {
chain.doFilter(request, response);
}
No need to copypaste the same over all JSP pages which would only be prone to IllegalStateException: response already committed errors.