karthik_rcs
Broken In
Let us assume i am request from a HTML page using GET METHOD in FORM ACTION parameter.
<FORM action = "HelloWorld">
HelloWorld is the Servlet class.
The code for HelloWorld is as follows.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
PrintWriter pw = response.getWriter();
pw.println("hi");
}
}
My Question is as follows. I am requesting from HTML using GET METHOD.
When the servlet gets initialized and service method is invoked on the servlet instance,
the service method calls the doPost or doGet based on my Http Method.
When i tried deploying this in Tomcat, i got HTTP 405 Error
HTTP method GET is not supported by this URL.
Why should i get this error when there is doGet of HttpServlet class and overrided doPost method in HelloWorld.
doPost has nothing to do in this situation as HTTP METHOD used is GET.
By the rule of inheritance we have doGet of HttpServlet in HelloWorld.
<FORM action = "HelloWorld">
HelloWorld is the Servlet class.
The code for HelloWorld is as follows.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
PrintWriter pw = response.getWriter();
pw.println("hi");
}
}
My Question is as follows. I am requesting from HTML using GET METHOD.
When the servlet gets initialized and service method is invoked on the servlet instance,
the service method calls the doPost or doGet based on my Http Method.
When i tried deploying this in Tomcat, i got HTTP 405 Error
HTTP method GET is not supported by this URL.
Why should i get this error when there is doGet of HttpServlet class and overrided doPost method in HelloWorld.
doPost has nothing to do in this situation as HTTP METHOD used is GET.
By the rule of inheritance we have doGet of HttpServlet in HelloWorld.