myeclipse运行用户注册界面出现错误
register.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'register.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<hr><br>Welcome to this <font color="green">Enroll(Register) Page</font>!<br>
<form action="do_register.jsp" method="get">
<br>
<h1>Please input your message:</h1><br>
Name:<input type="text" name="register_name"><br>
Pswd:<input type="password" name="register_password"><br>
<br><br><br>
<input type="submit"> <input type="reset"><br>
</body>
</html>
do_register.jsp
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'do_register.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
String Register_name=request.getParameter("register_name");
String Register_password=request.getParameter("register_password");
%>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/summer", "root", "123456");
Statement stmt=conn.createStatement();
//desogn the sql statement
String InsertSQL="INSERT INTO su(name,password) values('"+Register_name+"','"+Register_password+"')";
System.out.println(Register_name+"\t"+Register_password);
//do the query operation,and here is the most important sql statement.
int FLAG=stmt.executeUpdate(InsertSQL);
if(FLAG>0){
response.getWriter().write("Congratulation! REgister Success!");
}else{
response.getWriter().write("Sorry!Register Failed!\nPlease Retry it!");
}
}catch(SQLException e){
}
%>
</body>
</html>
页:
[1]