You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
package servlet.account;
|
|
|
|
import java.io.IOException;
|
|
import java.sql.SQLException;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.annotation.WebServlet;
|
|
import javax.servlet.http.HttpServlet;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import core.user.Student;
|
|
import core.user.User;
|
|
import core.user.utils.AccountManagement;
|
|
import error.GExcptAccount;
|
|
import error.GExcptSQL;
|
|
|
|
@WebServlet("/login")
|
|
public class login extends HttpServlet {
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
throws ServletException, IOException {
|
|
String id=request.getParameter("id");
|
|
String password=request.getParameter("password");
|
|
User user = null;
|
|
try {
|
|
user = AccountManagement.login(id,password);
|
|
} catch (GExcptSQL | SQLException gExcptSQL) {
|
|
gExcptSQL.printStackTrace();
|
|
} catch (GExcptAccount gExcptAccount) {
|
|
gExcptAccount.printStackTrace();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
request.getSession().setAttribute("user",user);
|
|
request.getRequestDispatcher("/home.jsp").forward(request,response);
|
|
}
|
|
}
|