⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginprocessaction.java

📁 学生信息管理系统
💻 JAVA
字号:
package action;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import dao.*;
import vo.*;
public class LoginProcessAction extends HttpServlet
{
	public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException ,ServletException
	{
		
		HttpSession session = req.getSession(true);
		if(session.getAttribute("user") != null)
			session.removeAttribute("user");
					
		String userName=req.getParameter("userName");
		String password=req.getParameter("password");

		UserLoginDao userLoginDAO=new UserLoginDao();
		
		boolean isright=userLoginDAO.checkUser(userName,password);
		if(isright)
		{
		
			UserVO user=userLoginDAO.getUser(userName);
			session.setAttribute("user",user.getUserName());
			String type=user.getType();
		
			if(type.equals("0"))
			{
				
				this.getServletContext().getRequestDispatcher("/AdminMain.jsp").forward(req,res);
				
			}
			else if (type.equals("1"))
			{
			this.getServletContext().getRequestDispatcher("/TeacherMain.jsp").forward(req,res);
				
			}
			else if (type.equals("2"))
			this.getServletContext().getRequestDispatcher("/StudentMain.jsp").forward(req,res);
			
		}
		res.setContentType("text/html");
		res.setCharacterEncoding("gb2312");
		PrintWriter out=res.getWriter();
		out.println("<html>");
		out.println("<head><meta http-equiv=refresh content=3;url=LoginForm.jsp>");
		out.println("<title>登陆失败</title></head>");
		out.println("<body background=6.jpg>");
		out.println("<br><br><br>");
		out.println("<h1 align=center ><font color=red>没有该用户或密码错误</font></h1><hr>");
		out.println("<br><br>");
		out.println("</body>");
		out.println("</html>");
	}	
	public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
	{
		doGet(req,res);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -