注册后,用户将看到此表单,其中注册表单中的所有详细信息都被捕获到数据库中
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h3>Email confirmation has been sent to your email address</h3>
<a href="http://localhost:6060/JSP_RegistrationAndLoginForm/LoginForm.jsp">click here to login</a>
</body>
</html>
登录表格:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<h3>Login Form</h3>
<form name="myForm" method="POST" action="ValidateLoginServlet2.do" onSubmit="return validateLogin()">
User name: <input type="text" name="uname"/>
Password: <input type="password" name="pwd"/>
<input type="Submit" name="submit" value="Submit" />
</form>
</body>
</html>
登录验证servlet:
public class ValidateLoginServlet2 extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// processRequest(request, response);
PrintWriter out = response.getWriter();
String username = request.getParameter("uname");
String password = request.getParameter("pwd");
try
{
Connection con = OracleDBConnection.getConnection();
PreparedStatement statement = con.prepareStatement("select username, password from registration where username =? and password=?");
statement.setString(1, username);
statement.setString(2, password);
ResultSet result = statement.executeQuery();
if(result.next())
{
response.sendRedirect("LoginSuccessful.jsp");
}
else
{
out.println("username and password are incorrect");
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
从登录表单提交用户名和密码java.sql.SQLException: ORA-00904: "PASSWORD": invalid identifier
答案 0 :(得分:1)
替换这两行
statement.setString(13, username);
statement.setString(14, password);
与
statement.setString(1, username);
statement.setString(2, password);