鱼C论坛

 找回密码
 立即注册
查看: 1680|回复: 0

[技术交流] myeclipse运行用户注册界面出现错误

[复制链接]
发表于 2020-4-8 12:12:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
cuowu.png


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>

cuowu.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-23 19:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表