Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Error 405 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error 405" Watch "Error 405" New topic
Author

Error 405

jvarkha
Greenhorn

Joined: Apr 04, 2000
Posts: 18
Hi,
I was trying out a program in which I'm taking info from a HTML form and printing it in an email and sending it to a dept...its from Wrox's Professional Java Server Programming book. I'm getting this 405 error where it says that the method GET is not supported by this URL. What does it mean by that ? And I'm using the POST method here in the program.
Any explanations would be welcome.
Thanks.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
From your posting I understand that you have a GET request from the form, but you have doPost in the program to handle the request.
If you have <form action="/jsp/form/process.jsp" method=post> in the HTML form then in your program you should override doPost method. To handle GET request add the following code for the doGet method,
doGet(HttpServletRequest request, HttpServletResponse response){
doPost(HttpServletRequest request, HttpServletResponse response)}
This will redirect your GET request to doPost method.
jvarkha
Greenhorn

Joined: Apr 04, 2000
Posts: 18
Thanks a lot Kartik. I added the doGet method and called the doPost method from there, as you said, and it worked fine. I got this message "Your request has been submitted." But does evey servlet that is using doPost and not doGet have to have the doGet and call doPost from there ? My form action specifies a servlet, just for info.
<FORM ACTION ="http://localhost:8080/servlet/TechSupport" METHOD = "POST">
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
If you have method=post then doPost will handle the request, method=get let doGet to handle the request. If you have <a href="path/servletSample"> then doGet will handle your request.
I hope this answers your question.
jvarkha
Greenhorn

Joined: Apr 04, 2000
Posts: 18
Thanks Kartik. The message in quotes in my above reply was to inform the user that the request has been accepted. It was part of the program. And the clarifications were helpful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error 405
 
Similar Threads
HTTP method GET is not supported by this URL
Sequence of request parameters
Error 405
HTTP Status 405
Error 405 with HttpUrlConnection when request web service