0

i m writing user registration page. i am getting HTTP Status 405 - HTTP method POST is not supported by this URL error though i have overwritten the doPost method

help me out through this Thanks

this is my registration.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
  <body>
  <form action="RegistrationServlet" method="post">
   <tr>
    <td>First Name</td>
    <td><input type="text" name="fname" value="" /></td>
   </tr>
   <tr>
      <td>Last Name</td>
      <td><input type="text" name="lname" value="" /></td>
   </tr>    
   <tr>
    <td>Email</td>
    <td><input type="text" name="email" value="" /></td>
   </tr>      
      <tr>
             <td>User Name</td>
             <td><input type="text" name="uname" value="" /></td>
            </tr>                      
            <tr>
                <td>Password</td>
                <td><input type="password" name="pass" value="" /></td>
        </tr>                  
         <tr>
          <td><input type="submit" value="Submit"></td>
          <td><input type="reset" value="Reset"></td>
           </tr>     
            <tr>
              <td colspan="2"> Already registered !!<a href="Login.jsp">Login here</a></td>
        </tr>
  </form>
</body>
</html>

this is my servlet

public class RegistrationServlet extends HttpServlet {
 
 public RegistrationServlet()
 {
 }
 
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
{
 
 String firstName=request.getParameter("firstName");
 String lastName=request.getParameter("lastName");
 String email=request.getParameter("email");
 String userName=request.getParameter("userName");
 String password=request.getParameter("password");
 
 RegistrationBean registrationBean =new RegistrationBean();
 registrationBean.setFirstName(firstName);
 registrationBean.setLastName(lastName);
 registrationBean.setEmail(email);
 registrationBean.setUserName(userName);
 registrationBean.setPassword(password);
}
}

This is the web.xml

  <display-name>MVC</display-name>
 <welcome-file-list>
 <welcome-file>Login.jsp</welcome-file>
  </welcome-file-list>
 <servlet>
  <description></description>
  <display-name>LoginServlet</display-name>
  <servlet-name>LoginServlet</servlet-name>
  <servlet-class>com.mvc.controller.LoginServlet</servlet-class>
 </servlet>
  <servlet>
  <description>Registraion page</description>
  <display-name>RegistrationServlet</display-name>
  <servlet-name>RegistrationServlet</servlet-name>
  <servlet-class>com.mvc.controller.RegistrationServlet</servlet-class>
 </servlet>
  <servlet-mapping>
  <servlet-name>LoginServlet</servlet-name>
  <url-pattern>/LoginServlet</url-pattern>
 </servlet-mapping>
 
 <servlet-mapping>
  <servlet-name>RegistrationServlet</servlet-name>
  <url-pattern>/RegistrationServlet</url-pattern>
 </servlet-mapping>
  
RandomSeed
  • 27,760
  • 6
  • 45
  • 82
Varun
  • 5,501
  • 18
  • 69
  • 107
  • Your HTML code looks weird. Look [Fiddle](http://jsfiddle.net/6pg8us3y/) for correction. When do you got this exception? Either while moving from login to registration or submitting your registration page. Have a look [SO](http://stackoverflow.com/questions/4297049/http-status-405-http-method-post-is-not-supported-by-this-url-java-servlet?rq=1) – Vinoth Krishnan Jan 13 '15 at 14:01
  • submitting the registration page. – Varun Jan 13 '15 at 16:43

1 Answers1

0

I was doing the code in eclipse. I created a class RegistrationServlet and extends the HttpServlet. the above error i was getting I searched on google but did no get the solution i checked the code 100 times but i did not find any error but finally what i did i created a servlet using eclipse and wrote the same code and the problem got sorted out.

i did not understand why this has happened.

but finally problem got sorted out

Thanks

Varun
  • 5,501
  • 18
  • 69
  • 107