Results 1 to 2 of 2

Thread: 404 error

  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default 404 error

    i got following error


    HTTP Status 404 - /StudentRegistrationForm

    --------------------------------------------------------------------------------

    type Status report

    message /StudentRegistrationForm

    description The requested resource (/StudentRegistrationForm) is not available.

    Program:

    package com;

    public class RegistrationForm {
    String name;
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getGender() {
    return gender;
    }
    public void setGender(String gender) {
    this.gender = gender;
    }
    public int getAge() {
    return age;
    }
    public void setAge(int age) {
    this.age = age;
    }
    String gender;
    int age;


    }
    HTML

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Student Registration Form</title>
    </head>
    <body bgcolor=thistle>
    <form action=../StudentRegistrationForm method="post">
    <h1 align="center">Student Registration Form</h1>
    <table>
    <tr>
    <td>
    Student Name
    </td>
    <td>
    <input type="text" name="studname">
    </td>
    </tr>
    <tr>
    <td>
    Gender
    </td>
    <td>
    <select name=gender size=1>
    <option value="male">Male</option>
    <option value="female">Female</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>
    Age
    </td>
    <td>
    <input type="text" name="age">
    </td>
    </tr>
    <tr>
    <td>
    <input type="submit" value="Add Student">
    </td>
    <td>
    <input type="reset" value=Clear>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    Coordinator
    package com;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;

    public class Coordinator {
    Connection con =null;
    Statement statement=null;
    String url="jdbc:mysql://localhost/c2c";
    String username="root";
    String password="admin";
    public boolean addStudent(RegistrationForm registrationForm)
    {
    boolean result=false;
    String inStudentSQL="insert into" + "studregmaster values("+registrationForm.getName()+""+","+registr ationForm.getGender()+""+","+registrationForm.getA ge()+")";
    try
    {
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection(url,username,passw ord);
    statement=con.createStatement();
    statement.executeUpdate("insert into" + "studregmaster values("+registrationForm.getName()+""+","+registr ationForm.getGender()+""+","+registrationForm.getA ge()+")");
    result=true;
    }

    catch(Exception se)
    {
    System.out.println(se.toString());
    }
    return result;
    }

    public void modifyStudent()
    {


    }
    public void removeStudent()
    {

    }
    }

    Servelt

    package com;

    import java.io.IOException;
    import java.io.PrintWriter;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class StudentRegistrationForm
    */
    public class StudentRegistrationForm extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public StudentRegistrationForm() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub

    PrintWriter out=response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<form>");
    RegistrationForm registrationForm = new RegistrationForm();
    registrationForm.setName(request.getParameter("txt Name"));
    registrationForm.setGender(request.getParameter("g ender"));
    registrationForm.setAge(Integer.parseInt(request.g etParameter("txtage")));

    Coordinator coordinator=new Coordinator();
    boolean status=coordinator.addStudent(registrationForm);
    if(status==true)
    {
    out.println("Registration Confirmed");
    }

    else
    {
    out.println("System Error");
    }
    out.println("</form>");
    out.println("</body");
    out.println("</html>");

    }

    }

    we.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>JSP</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <description></description>

    <display-name>StudentRegistrationForm</display-name>
    <servlet-name>StudentRegistrationForm</servlet-name>
    <servlet-class>com.StudentRegistrationForm</servlet-class>

    </servlet>
    <servlet-mapping>
    <servlet-name>StudentRegistrationForm</servlet-name>
    <url-pattern>/StudentRegistrationForm</url-pattern>
    </servlet-mapping>
    </web-app>

    Please anybody to solve my problem?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: 404 error

    Please use code tags when posting code.
    Java Code:
    action=../StudentRegistrationForm
    Why the '../', and shouldn't that be in quotes anyway?

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •