package com.demo;

import com.dao.StudentDao;
import com.dao.StudentDaoImpl;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ WebServlet(name = "StudentServlet", urlPatterns = { "/addStudent.jsp" })
public class StudentServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username" );
        String password =request.getParameter("password");
//        System.out.print("ok2");
        //检索信息正确
        listStudent(request,response);
        RequestDispatcher rd = request.getRequestDispatcher("StudentPage.jsp");
        rd.forward(request, response);
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    //添加学生方法
    public void listStudent(HttpServletRequest request,
                            HttpServletResponse response)
            throws ServletException, IOException {
        StudentDao dao = new StudentDaoImpl();
        String username = request.getParameter("username" );
        String password =request.getParameter("password");
        Student student = dao.listStudent(password);
    }

    public void removeStudent( HttpServletRequest request,
                               HttpServletResponse response)
            throws ServletException, IOException {

    }


    public void addStudent( HttpServletRequest request,
                            HttpServletResponse response)
            throws ServletException, IOException {

    }
}
