userlogincheck.jsp

来自「汽车展销的网站开发」· JSP 代码 · 共 42 行

JSP
42
字号
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312" import="java.sql.*"%>
<jsp:useBean id="login" class="Bean.DbConn" scope="session"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
	request.setCharacterEncoding("GBK");
	ResultSet rs=null;
	String user_name=request.getParameter("user_name");
	String user_psw=request.getParameter("user_psw");
	
	String sql="select * from member where user_name='"+user_name+"' and user_psw='"+user_psw+"'";
	
	try{
	login.open();
	rs=login.executeQuery(sql);
	if(!rs.next())
	{
		//System.out.print("1121");
		out.println("<script>alert('输入的用户不存在或密码错误!');window.history.go(-1);</script>");
	}
	else
	{
		//System.out.print("1131");
		session.setAttribute("user",rs.getString("user_name"));
		response.sendRedirect("index.jsp");
	}
	}
	catch(Exception e){
		out.println(e.getMessage());
	}
	
%>
</body>
</html>

⌨️ 快捷键说明

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