Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error 400:  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when iam doing 3rd chapter example in HFSJ book my servlet is producing following error Error 400: HTTP method GET is not supported by this URL

as well as when iam clicking the html submit button it shows page cannot found please help me.im sruggling this whole day
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you HTML/JSP page has:

<form action="/someservlet">
...
</form>

make sure that the servlet class denoted by this URL pattern, properly implements "public void doGet(HttpServletRequest,HttpServletResponse)"

I think, you must have implemented "doPost()" in your servlet and not "doGet()". That could be reason for the error.

To avoid these scenarios couple your doGet() and doPost(), i.e., implement doGet() as follows:

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It means that you are not implemented doGet(request,response) in your servlet.

The default method for html form is Get and Not Post.Hence the servlet is looking for doGet method and not for doPost.
and one more thing to note is,the service method,looks the http method and calls that method in servlet.In this case it is Get and hence it calls doGet method.

regards
Kalpana.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should also make sure that your form has the POST method specified..

<form action="/someServlet" method="POST">
form stuff here
</form>
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the exam you will need to know that the Get method is the default if you do not indicate a method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!