jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HTTP status 405 Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HTTP status 405 Error" Watch "HTTP status 405 Error" New topic
Author

HTTP status 405 Error

pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
Person.class is in D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
public class Person{
private String name;

public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}

BeanEx.class is in D:\Tomcat4.1\webapps\foo\WEB-INF\classes

package foo;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeanEx extends HttpServlet{
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException {
foo.Person p = new foo.Person();
p.setName("Evan");
request.setAttribute("person",p);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}

result.jsp in D:\Tomcat4.1\webapps\foo

<html>
<body>
person is: <%= request.getAttribute("person") %>
</body>
</html>

web.xml in D:\Tomcat4.1\webapps\foo\WEB-INF

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>BeanPerson</servlet-name>
<servlet-class>foo.BeanEx</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BeanPerson</servlet-name>
<url-pattern>/Tester.do</url-pattern>
</servlet-mapping>
</web-app>

http://localhost:8080/foo/Tester.do is giving the error

HTTP Status 405 - HTTP method GET is not supported by this URL

where is it going wrong?


Thanks,<br />Pallavi
Raju Sri
Ranch Hand

Joined: Mar 10, 2004
Posts: 108
Hi Pallavi,

Obviously your servlet doesn't implement doGet method, that's why you are getting error while accessing http://localhost:8080/foo/Tester.do through browser.Whenever we access some thing directly on the browser, GET method will be triggered.

So try calling the Tester.do from html page like below then POST will be triggered.

<html><body>
<form name="test" action="Tester.do" method="POST">
<input type=submit>
</form>
<body></html>


SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3<br />SCDJWS 1.4
pallavi utukuri
Ranch Hand

Joined: Feb 10, 2004
Posts: 182
Thanku Raju, i forgot that Get is the default...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP status 405 Error
 
Similar Threads
Status 405 - HTTP method GET is not supported by this URL
EL question
404 again!
HFSJ book:Bean Example Page 357
EL Again!