jsp第9个作业
regist.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>Regist</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>
<center>
<form action="doregist.jsp" method="post">
用户名:<input type="text" name="uname" value=""><br>
密 码:
<input type="password" name="upwd" value=""><br>
email: <input type="text" name="email" value=""><br>
<input type="submit" value="注册">
<a href="login.jsp">返回</a>
</form>
</center>
</body>
</html>
doregist.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ql.dao.*" %>
<%@page import="com.ql.entity.Users" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("utf-8");
String uname = request.getParameter("uname");
String upwd = request.getParameter("upwd");
String email = request.getParameter("email");
Users user = new Users();
user.setUsername(uname);
user.setPassword(upwd);
user.setEmail(email);
MsgDao md = new MsgDao();
md.addUser(user);
request.getRequestDispatcher("login.jsp").forward(request, response);
%>
//注册方法insert
public boolean addUser(Users user){ Connection con=null;
try{
//获取连接
con = getConnection();
//书写SQL语句
String sql = "insert into Usersd(username,PASSWORD,email) values(?,?,?)";
PreparedStatement st =con.prepareStatement(sql);
st.setString(1,user.getUsername());
st.setString(2, user.getPassword());
st.setString(3, user.getEmail());
int row = st.executeUpdate();
if(row>0){
//发送成功
return true;
}
closeAll(con, st, null);
}catch(SQLException e){
e.printStackTrace();
}
return false;
}



jsp第9个作业的更多相关文章
- JSP第十一次作业
1.第十二周上机作业(邮件功能)的控制层代码改用为servlet实现.2.学习通发布了考试,截止到本周六. com.gd.dao BaseDao 1 package com.gd.dao; 2 3 ...
- jsp内置对象作业3-application用户注册
1,注册页面 zhuCe.jsp <%@ page language="java" contentType="text/html; charset=UTF-8&qu ...
- jsp内置对象作业2-留言簿
1.留言簿页面:liuYan.jsp <%@ page language="java" contentType="text/html; charset=UTF-8& ...
- jsp内置对象作业1-用户登录
题目:编写一个jsp程序,实现用户登录,当用户输入的用户名或密码错误时,将页面重定向到错误提示也,并在该页面显示30秒后,自动返回到用户登录页面. 1.用户登录页面 <%@ page langu ...
- jsp第七周作业
1.p78-p79的例4-9 <%@ page language="java" import="java.util.*" pageEncoding=&qu ...
- jsp第六次作业
1. <%@ page language="java" import="java.util.*" pageEncoding="utf-8&quo ...
- jsp第三次作业
1.在jsp页面中使用include动态标记加载音频 <%@ page language="java" import="java.util.*" page ...
- JSP第八次作业
数据库test 中建个表 stu(stuid 主键 自动增长 ,用户名,密码,年龄) 1.设计一个注册页面,实现用户注册功能2.设计一个登陆页面,实现用户名密码登陆3.两个页面可以互相超链接 1 pa ...
- JSP第七次作业
1.做一个图书类Book id,name,price ,get,set访问器,构造方法2个,1个无参,1个有参做一个测试类,在main中创建3个图书对象,放到list集合中.做一个菜单,可以添加,删除 ...
- JSP第五次作业
1.教材P78-79 例4-9 1 <%@ page language="java" import="java.util.*" pageEncoding ...
随机推荐
- Unity 读取Json文件、创建Json文件
using System.IO; using UnityEngine; public class ReadJson:MonoBehaviour { public static TestSetting ...
- 提交from表单,method与浏览器请求显示不一致
<from method="post" action ="/login_check"> 用户名:<input type="text& ...
- oracle学习之undo的基本知识及事务与undo、数据块的关联
通过自己学习总结的这些undo知识能够让大家都能深刻了解oracle的undo相关原理. 一.undo撤销表空间的作用 撤销表空间通常称为undo表空间:undo表空间的段也称为撤销段或undo段.回 ...
- Unity实现手机录音功能
using UnityEngine;using System.Collections;public class MicPhoneScripts : MonoBehaviour{ private ...
- wpf treeview 绑定图标方式
<TreeView Grid.Row="0" Grid.Column="0" x:Name="foldersItem" Selecte ...
- @Service注解
@Service注解的作用之一就是添加在Service层做Bean实例化, 在遇到service层方法有多个实现时也可指定@Service(name=""),并在controlle ...
- vue store用法
import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) 首字母不能大写 export default new Vuex.Store({ ...
- 2.VS编写XML实例程序
在VS中编写XML实例程序 1.如下,在 VS 中分别新建 XML 文件.XML 解析类.XML 实体类 2.在项目中代码,如下 (1)XML 文件(注:在 VS 解决方案资源管理器中选中 XML ...
- gym102586C Sum Modulo
题意: 给你 \(n,m,k\) 以及\(p_i(1\le i\le n)\) ,保证 \(\sum p_i=1\) 你有一个数 \(X\),一开始 \(X=0\) 每次你会生成一个随机数 \(A\) ...
- 2019-2020-1 20199318《Linux内核原理与分析》第十一周作业
<Linux内核原理与分析> 第十一周作业 一.预备知识 什么是ShellShock? Shellshock,又称Bashdoor,是在Unix中广泛使用的Bash shell中的一个安全 ...