• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTP status 405 Error

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanku Raju, i forgot that Get is the default...
 
I am going to test your electrical conductivity with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic