@ WebServlet ("/ LoginAction")
public class LoginAction extends HttpServlet {
    protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}

    protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession ();

        String login = request.getParameter ("emp_id");
        String password = request.getParameter ("emp_pass");
        List<Bean>bean = Login.search (login, password);← An error occurs here
        request.setAttribute ("bean", bean);
        RequestDispatcher dispatcher =
                request.getRequestDispatcher ("index.jsp");
        dispatcher.forward (request, response);
public static List<Bean>search (String empId, String empPass) throws Exception {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        Bean bean = null;
        List<Bean>beanList = new ArrayList<>();
        try {
            connection = DBManager.getConnection ();
            String sql = "SELECT * FROM employee WHERE emp_id =? AND emp_pass =?";
            preparedStatement = connection.prepareStatement (sql);
            preparedStatement.setString (1, empId);
            preparedStatement.setString (2, empPass);
            resultSet = preparedStatement.executeQuery ();
            while (resultSet.next ()) {
                Bean empBean = new Bean ();
                empBean.setEmpId (resultSet.getString ("emp_id"));
                empBean.setEmpName (resultSet.getString ("emp_name"));
                empBean.setEmpPass (resultSet.getString ("emp_pass"));
                beanList.add (empBean);
        } catch (Exception e) {
            e.printStackTrace ();
        } finally {
            DBManager.close (resultSet);
            DBManager.close (preparedStatement);
            DBManager.close (connection);
        return beanList;

`` `###

Management system using Servlet, DAO, DB and JSP
I make it with Eclipse.
I want to create a screen where I can log in with the ID and PASSWORD stored in the DB.
I want to use a session at that time.

I referred to various websites, but I can't make them.

If i have any advice, thank you

  • Answer # 1

    There are books and learning sites for beginners in the case of servlets and JSPs, so it is better to learn from environment construction and exercises from there.

    If it is a learning site, TECHSCORE: JavaEE is better.