chkuser.jsp

来自「面向对象软件工程案例」· JSP 代码 · 共 35 行

JSP
35
字号
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html; charset=GBK"%>
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=GBK">
<title>用户登录验证</title></head>

<body bgcolor="#9999FF">
<div align="center">
<%
	String url = "main.jsp";
	String logName=new String();
	String password=new String();
   	logName = request.getParameter("username");
   	password = request.getParameter("userpassword");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	Connection con=DriverManager.getConnection("jdbc:odbc:bookStore");
	Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
 	String SQL=new String();
	SQL = "select * from client where logName='" +logName + "' and password='" + password + "'";
        ResultSet rs = stmt.executeQuery(SQL);
   	if(rs.next()){
   		session.setAttribute("logName",logName);
   	        response.sendRedirect(url);
  			}
		else{
		response.sendRedirect("loginErr.htm");
	}
	rs.close();
	stmt.close();
	con.close();
%>
</div>
</body>
<html>

⌨️ 快捷键说明

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