Problem :
HTTP Status 405 - HTTP method GET is not supported by this URL
Solution :
This is always caused by following two reasons
1) You do not have a valid doGet() method, when you type the servlet’s path
in address bar directly, the web container like Tomcat will try to invoke the
doGet() method.
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException{
}
2) You made a HTTP post request from a HTML form, but you do not
have a doPost() method to handle it. The doGet() cannot handle the “Post” request.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException{
}
Example of wrong doGet() and doPost() method
protected void doPost(HttpServletRequest request,
HttpServletResponse response, PrintWriter Out){
}
These two methods get() and post() must have only
2 parameters otherwise it will not be called.
No comments:
Post a Comment