0

I have one jsp file which is accessing servlet class DisServlet which is calling a method from java class EmpDao. When I try to run it on tomcat server it is giving the above error. It is working fine for AddServlet servlet . Although all the classes and servlets are in proper packages. Can someone help me out on this. Attaching the image for the following error

Display Employee

Getting value from database and pressing go and after pressing go getting above error

doGet() of DisServlet

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    EmpDao ed = new EmpDao();
    String i = (String) request.getAttribute("id1");
    ed.dis(i);
}

EmpDao class

public class EmpDao {
    private MyConnection mcon;
    public EmpDao(){

        mcon=new MyConnection();
    }
    public int add(Employee emp)
    {

        PreparedStatement pst;
        int rec=0;
        try
        {
            Connection con=mcon.getConn();
            pst = con.prepareStatement("insert into Employee1    values(?,?,?,?,?)");

            pst.setString(1, emp.getId());
            pst.setString(2, emp.getName());
            pst.setString(3, emp.getDesig());
            pst.setString(4, emp.getDept());
            pst.setInt(5, emp.getSalary());

            rec=pst.executeUpdate();
            con.close();

        }catch(Exception e){
            System.out.println("Connection Problem");
        }
        return rec;
    }

    public void dis(String s)
    {
        System.out.println("Here reached"+s);
    }
}

disJSP file

<body>
<form action="DisServlet">
    <pre>

        Enter the employee id to display : <input type ="text" name ="id1">
        <input type="submit" value ="Go">
    </pre>
</form>

web.xml file

<servlet>
<description></description>
<display-name>DisServlet</display-name>
<servlet-name>DisServlet</servlet-name>
<servlet-class>com.accenture.training.DisServlet</servlet-class>

Servlet Mapping

<servlet-mapping>
<servlet-name>DisServlet</servlet-name>
<url-pattern>/DisServlet</url-pattern>

Navin Nagrani
  • 13
  • 1
  • 1
  • 5

0 Answers0