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

📄 dengluservlet.java

📁 登录 使用了Ajax 还有重设密码的功能
💻 JAVA
字号:
package servlet;
import connection.database.*;
import java.io.*;
import bean.login.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import DAO.*;
public class DengluServlet extends HttpServlet
{
	public void init(ServletConfig config) throws ServletException
	{
		super.init(config);
	}
	public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
	{
		response.setContentType("text/html;charset=gb2312");
		//接收并处理从Login.jsp提交上的信息
		String yourId=request.getParameter("id");//用户名
		System.out.println("yourId="+yourId);
		try{
			byte[]bb=yourId.getBytes("gb2312");
			yourId=new String(bb,"ISO-8859-1");
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		String yourPassword=request.getParameter("password");//密码
		System.out.println("yourPassword="+yourPassword);
		String s=null;
	    
	    DAO dao=new DAO();
	    if(dao.lookDenglu(yourId,yourPassword)){
	    	s=yourId+"已登录!";
	    }else
		  {
		       s="登录失败,用户名或密码错误!";
		  }	 
		request.getSession().setAttribute("denglu",s);
	    //将servlet请求转发给denglu.jsp
	    RequestDispatcher dispather=request.getRequestDispatcher("denglu.jsp");
	    dispather.forward(request,response);
	} 
	public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
	{
		doPost(request,response);
	}
}

⌨️ 快捷键说明

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