File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error 400:

 
ramachandran swaminathan
Ranch Hand
Posts: 43
  • 0
  • 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
 
Ashwin Kumar
Greenhorn
Posts: 27
  • 0
  • 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:

 
kalpana ram
Ranch Hand
Posts: 38
  • 0
  • 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.
 
Ken King
Greenhorn
Posts: 13
  • 0
  • 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>
 
Michael Ku
Ranch Hand
Posts: 510
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic