File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error 400: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error 400:" Watch "Error 400:" New topic

Error 400:

ramachandran swaminathan
Ranch Hand

Joined: Nov 27, 2006
Posts: 43
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 sruggling this whole day

target scwcd.
Ashwin Kumar

Joined: Oct 13, 2005
Posts: 27
If you HTML/JSP page has:

<form action="/someservlet">

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:

SCJP 1.4<br />SCBCD 5.0<br />SCWCD 1.4 (Preparing)
kalpana ram
Ranch Hand

Joined: May 20, 2007
Posts: 38

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.

Ken King

Joined: Sep 17, 2007
Posts: 13
You should also make sure that your form has the POST method specified..

<form action="/someServlet" method="POST">
form stuff here
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
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:
subject: Error 400:
It's not a secret anymore!