Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package servlets;
- import java.io.IOException;
- import javax.servlet.RequestDispatcher;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import beans.LoginBean;
- @SuppressWarnings("serial")
- public class LoginServlet extends HttpServlet
- {
- public void init() throws ServletException
- {
- super.init();
- log("servlet init");
- }
- public void destroy()
- {
- log("servlet destroy");
- super.destroy();
- }
- public void doPost(HttpServletRequest request,HttpServletResponse response)
- throws ServletException, IOException
- {
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- String url = "";
- LoginBean lb = new LoginBean();
- if(lb.checkUser(username, password))
- {
- request.setAttribute("login", lb);
- url = "WEB-INF/jsp/login.jsp";
- }
- else {
- request.setAttribute("login", lb);
- url = "loginpage.jsp";
- }
- RequestDispatcher dispatcher = request.getRequestDispatcher(url);
- dispatcher.forward(request, response);
- }
- }
Add Comment
Please, Sign In to add comment