• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP method GET is not supported by this URL

 
naidu rasagna
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class DisplayPage extends HttpServlet {
public void doPost(HttpServletRequest req,HttpServletResponse resp)throws IOException
{
PrintWriter out = resp.getWriter();
out.println("This is post");
}
}
I am getting the error
HTTP method GET is not supported by this URL.And when i write like

public void doGet(HttpServletRequest req,HttpServletResponse resp)
{
doPost(req,resp);
}
its working fine .May i know why??

Thank you......
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about it.

doGet handles get requests, doPost handles post requests. If you do not
have a doGet method in your servlet, get requests will not work, and the
default request (what you get accessing a page without doing a post from
a form, or something similiar) is a get request.
 
Ravindra Rawat
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checkout the implementation of service method of HttpServlet. When you access a servlet "service" method will be invoked which will invoke doGet,doPost depending on request header.

In your case default implementation of doGet is getting invoked which may be throwing an Exception.

- Ravindra
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"rasagna", "Ravindra",

We're a friendly bunch here at the ranch, but we take our display names very seriously.

We require display names to be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display names, since accounts with invalid display names get deleted, often without warning.

thanks,
Dave.
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ravindra:
Checkout the implementation of service method of HttpServlet. When you access a servlet "service" method will be invoked which will invoke doGet,doPost depending on request header.

In your case default implementation of doGet is getting invoked which may be throwing an Exception.

- Ravindra


No it is not causing an "error". What he is seeing is exactly what the
default implementation of HttpServlet.doGet does. If he does not
override the method, then the servlet will not process it. How should
HttpServlet know what you want to do with your servlet?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!