How to block POST/GET Method in a Web application deployed in application server.
so that http status code 405 [Method Not Allowed] will be thrown when it access via a blocked method.
Description for HTTP Status code [405] : A request was made of a resource using a request method not supported by that resource;[2] for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.
If by blocking you mean not accepting any incoming GET / POST
requests, you have two solutions:
Filter
that will block the requestsIn the filter, you could do for instance:
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
((HttpServletResponse) response).sendError(405,
"the error message" );
}