process.jsp

来自「课程设计中的在线书店源码」· JSP 代码 · 共 31 行

JSP
31
字号
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="conn" property="connStr" value="jdbc:odbc:user"/>
<%
	session.setMaxInactiveInterval(-1);
	//获取用户名
	String username=request.getParameter("username");
	//将获得的用户名进行内码转换,防止中文乱码问题
	username=new String(username.getBytes("8859_1"));
	//获取口令
	String password=request.getParameter("password");
	//对口令进行编码转换
	password=new String(password.getBytes("8859_1"));
	ResultSet  rs=null;
	String sql="select * from user where name='"+username+"' and password='"+password+"'";
	rs = conn.executeQuery(sql);
	if(rs.next())
	{
		session.setAttribute("loginId",rs.getString("id"));
		session.setAttribute("username",rs.getString("name"));
		rs.close();
		conn.close();
		response.sendRedirect("home.jsp");
	}
	else   	
	{
		rs.close();
		conn.close();
		response.sendRedirect("login.htm");
	}
%>

⌨️ 快捷键说明

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