processregister.jsp

来自「这是本人做的第一个JAVA网站,请大家多提意见」· JSP 代码 · 共 38 行

JSP
38
字号
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="pool" scope="application" class="PoolBean"/>
<html>
<head>
<title>正在处理,请稍后......</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<center>
  正在处理,请稍后...... 
<%
	String username=new String(request.getParameter("username").getBytes("8859_1"));
	String password=new String(request.getParameter("password").getBytes("8859_1"));
	String question=new String(request.getParameter("question").getBytes("8859_1"));
	String answer=new String(request.getParameter("answer").getBytes("8859_1"));

	Connection conn=pool.getConnection();
	Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);  
	String sql1="SELECT * FROM Customers WHERE Username='"+username+"'"; 
	ResultSet rsLogin=stmt.executeQuery(sql1);

	if(rsLogin.next()){
		response.sendRedirect("registerFailure.jsp");
	}else{
		String sql2="INSERT INTO Customers(Username,Password,Question,Answer) VALUES('"+username+"','"+password+"','"+question+"','"+answer+"')"; 
		stmt.executeUpdate(sql2);
		response.sendRedirect("registerOK.jsp");
	}

	rsLogin.close();
	stmt.close();
	pool.releaseConnection(conn);
%>
</center>
</body>
</html>

⌨️ 快捷键说明

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