protected void Login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); if (username == null || password == null) { response.sendRedirect("login.jsp"); return; } UserBean userBean = new UserBean(); boolean isValid = userBean.valid(username, password); if (isValid) { HttpSession session = request.getSession(); session.setAttribute("username", username); response.sendRedirect("welcome.jsp"); return; } else { response.sendRedirect("login.jsp"); return; } }