导航:首页 > 编程语言 > jsp制作注册页面

jsp制作注册页面

发布时间:2022-09-18 02:31:34

① 如何用jsp 做一个简单的登录注册页面(在没有数据库支持的情况下)

没有数据库,建议你使用xml来存放数据,这样方便修改,或者使用*.properties文件存放,将实现定义的用户存入进去

② 如何在jsp页面上实现点击注册按钮,弹出一个窗体来注册(类似于百度贴吧的登录和注册),求详细代码和注释

jsp中的注册弹出新窗口是通过window.open一个新页面来实现的。
页面register.jsp代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="cn.wy.Pet.User" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员注册例子讲解</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FF0000;
font-weight: bold;
}
.STYLE2 {color: #FF0000}
.STYLE3 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>

<body style="font-size:12px">
<form id="form1" name="form1" method="post" action="<%=actionStr%>reg">
<p align="center"><br />
<span class="STYLE3">用户注册</span></p>
<table width="582" height="302" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#BCACD2">
<tr>
<td width="80" align="right">用户名:</td>
<td width="496" align="left"><input name="userName" type="text" id="userName" size="16" maxlength="16" />
<span class="STYLE1">*</span> 3~16位字母或者数字(如:8hack)</td>
</tr>
<tr>
<td align="right">密码:</td>
<td align="left"><input name="password1" type="text" id="password1" size="16" maxlength="16" />
<span class="STYLE1">* </span> 3~16位字母或者数字(如:abc123)</td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td align="left"><input name="password2" type="text" id="password2" size="16" maxlength="16" />
<span class="STYLE1">*</span> 必须和上面输入的密码相同</td>
</tr>
<tr>
<td align="right">电子邮件:</td>
<td align="left"><input name="email" type="text" id="email" maxlength="20" />
<span class="STYLE1">*</span> 找回密码和联系用(如:[email protected])</td>
</tr>
<tr>
<td align="right">联系电话:</td>
<td align="left"><input name="tel" type="text" id="tel" size="20" maxlength="20" />
如(0871-8888888,13888853113)</td>
</tr>
<tr>
<td align="right">联系地址:</td>
<td align="left"><input name="address" type="text" id="address" maxlength="50" /></td>
</tr>
<td height="40" colspan="2" align="center"><input type="submit" name="Submit" value="确认注册" />
<input type="reset" name="Submit2" value="重新填写" /></td>
</tr>
</table>
</form>
</body>
</html>
后台servlet的处理:
public class reg extends HttpServlet
{
public reg()
{
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
DBConnection dbc=null;
String userName;
String psd;
String email;
String tel;
String address;
int popedom;
response.setContentType("text/html;charset=UTF-8");
out = response.getWriter();
try{
dbc = new DBConnection();
PreparedStatement ps = null;
userName = request.getParameter("userName");
psd = login.encrypt(request.getParameter("password1").toString());
email = request.getParameter("email");
tel = request.getParameter("tel");
address = request.getParameter("address");
popedom = Integer.parseInt(request.getParameter("popedom"));
if (userName != null && psd != null && email != null)
{
ps = dbc.getCon().prepareStatement("insert into [User](UName,Upass,UEmail,UTel,UAddress,UPopedom) values(?,?,?,?,?,?)");
ps.setString(1, userName);
ps.setString(2, psd);
ps.setString(3, email);
ps.setString(4, tel);
ps.setString(5, address);
ps.setInt(6, popedom);
ps.execute();
System.out.print("新用户注册:" + request.getParameter("userName") + " ");
out.print("<script>alert('恭喜您:注册成功!现已经登录到网站!');history.go(-1)</script>");
}
if (dbc != null)
dbc.dbClose();
}
catch(SQLException ex)
{
out.print("<script>alert('注册失败!数据库连接错误!');history.go(-1)</script>");
ex.printStackTrace();
if (dbc != null)
dbc.dbClose();
}
}
}

③ 求大神写一下jsp的简单的注册界面代码。

1.需要一个jsp页面:
//login.jsp核心代码:
<form action="${pageContext.request.contextPath}/servlet/UserServlet" method="post">
<input type="text" name="loginname" /><input type="password" name="password"/>
<input type="submit" value="登录"/>
</form>
2.需要一个servlet来验证登录信息
//UserServlet 核心代码
class UserServlet extends HttpServlet{
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
process(request, response);
}
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
process(request, response);
}
private void process(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
String loginname = request.getParameter("loginname");
String password = request.getParameter("password");
//创建一个service来处理业务逻辑(包括查询数据库操作)
UserService service = new UserService();
boolean bool = service.validateUser(loginname,password);
if(!bool){
pw.println("用户名或密码错误");
}else{
pw.println("登录成功");
}
}
3.需要一个service处理业务逻辑(包括查询数据库操作)
//UserService 核心代码
public class UserService{
/**
*查询数据库验证用户是否存在,返回boolean
*/
public boolean validateUser(String loginname,String password){
boolean bool = false;
Connection conn = null;
PreparedStatement ps = null;
//这里以mysql为例
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
String sql = "select login_name,pass_word from t_user where login_name=? and pass_word=?";
ps = conn.prepareStatement(sql);
ps.setString(0, loginname);
ps.setString(1, password);
ResultSet rs = ps.executeQuery();
if(rs.next()){
bool = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
if(conn != null){
conn.close();
conn = null;
}
if(ps != null){
ps.close();
ps = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return bool;
}
}

④ 如何利用JSP制作一个简单注册登陆界面

下面的html实现了你所说的功能,使用的时候把代码放到页面中效果是一样的:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</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">
<script type="text/javascript">
var fileId=2;
function addImage(){
var imgBtn=document.getElementById("imgBtn");
imgBtn.parentNode.removeChild(imgBtn);
var imgBtn1=document.createElement("input")
imgBtn1.type="button";
imgBtn1.value = "添加";
imgBtn1.id = "imgBtn";
imgBtn1.onclick=addImage;

var imgTd=document.getElementById("imgTd");
var imgDiv=document.createElement("div");
var fileInput= document.createElement("input");
fileInput.type="text";
fileInput.value="第"+fileId+"个";
fileInput.id=fileId;
fileInput.name="imgFile";
imgDiv.appendChild(fileInput);
imgDiv.appendChild(imgBtn1);
imgTd.appendChild(imgDiv);
fileId=fileId+1;
}
</script>

</head>
<body>
<form action=""
method="post" >
<table width="452" border="0">
<tr>
<td>
用户名:
</td>
<td id="imgTd">
<div>
<input name="imgFile" type="text" value="第1个" />
<input type="button" id="imgBtn" value="添加" onClick="addImage()" />
</div>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="添加" />
</td>
<td align="center">
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>

</body>
</html>

⑤ jsp语言编写注册页面

因为现在只做PHP,所以,没法直接给出你JSP代码了啊,不过原理上是一样的,我说一下我的思路,你参考一下吧。

你说的3个不同的身份登录,那么其实就是指系统应该具有3种角色了;根据这个分析,你在用户注册的时候,一般要有一种或两种默认的角色,并且这些角色可以通过后台来管理,在用户表中,可以通过一个属性来记录这些值,如user_role,里面可以记录0,1,2来分析代表三种角色
并且再增加一个属性,page_mod_count,里面存放允许修改的次数,再增加一个属性modified,来记录已经修改的次数,已经修改的次数好办,因为登录后,可以通过相应的Session来找到是哪个用户。

而用户在修改这个页面的时候,这个页面必须通过查询获取了相关的数据,既然是查询,那么已修改次数和允许修改次数的比较也能顺便查出来,如果超过了允许值,直接提示不能修改,或将页面的form的每个元素都设为disable即可。

上面只是原理,因为电脑N久没有配置JSP环境了,不好意思了呵呵。

⑥ JSP做一个校友录创建班级注册页面

可以做的。
随着B/S模式越来越受到人们的接受,各种在浏览器中给我们带来的服务应运而生,更多的用户花费更多的时间在这些系统中,在随着潮流的同时,我便想利用这次毕业设计的时间来做一个对广大学生们有帮助的系统,给他们的生活带来一些方便。现在经济发展和改革开发的不断深化,同学们之间的联系方式也越来越多,不再是原先纸质版同学录,在日常的生活中,QQ、电子邮件、微信、MSN等的不断发展,人与人之间的交流也变的越来越方便,但是有很多人希望能有一个属于自己的网络空间。本文设计的校友录系统是集合了web开发的优点,结合自己所学的web开发知识以及oracle数据库和生活中的一些常识,做出的一个简化版的系统,可以实现一些简单的功能,帮助同学们之间进行交流互动,了解学校的动态。
主要包括了后台数据库系统的设计以及前段应用程序的开发两个方面。对于前者,则需要保证数据的通用性、一致性和安全性,而对于应用程序开发,则尽量做到功能完备,让用户有一个更好的体验。我将利用jsp、oracle等技术,并用SSM三大框架给校友录网站的开发带来了很大的方便。

⑦ 编写用户注册于登录的JSP页面的全部程序代码

3个jsp文件,第一个是login.jsp,第二个是judge.jsp,第三个是afterLogin.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登录页面</title>
</head>
<body>
<form name="loginForm" method="post" action="judgeUser.jsp">
<table>
<tr>
<td>用户名:<input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密码:<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><input type="submit" value="登录" style="background-color:pink"> <input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>身份验证</title>
</head>
<body>
<%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
String password = request.getParameter("password");
if(name.equals("abc")&& password.equals("123")) {

%>
<jsp:forward page="afterLogin.jsp">
<jsp:param name="userName" value="<%=name%>"/>
</jsp:forward>
<%
}
else {
%>
<jsp:forward page="login.jsp"/>
<%
}
%>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登录成功</title>
</head>
<body>
<%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
out.println("欢迎你:" + name);
%>
</body>
</html>

⑧ 怎样用jsp和servlet实现一个注册页面

1、定义用户信息表
2、做一个填写信息页面,其中有一个FORM
3、服务器端(JSP/SERVLET)接收FORM提交的信息,处理数据、插入数据库

⑨ 用html和jsp怎么做登陆注册页面

jsp语言只是嵌套了服务器端脚本语言,去掉的话和html一样。写代码的话只是在html中写好,套入jsp中就ok

阅读全文

与jsp制作注册页面相关的资料

热点内容
黑人教室的英语作弊教师 浏览:651
oracleexp指定版本 浏览:150
李银美韩国 浏览:319
u12linux 浏览:783
限制级视频网 浏览:636
.ybci.waq ?x 浏览:765
腾讯文件苹果板 浏览:173
外国女同电影 浏览:336
为什么同一文件压缩比原文大 浏览:206
北京哪里有数控机床编程 浏览:135
男儿当自强版本 浏览:164
恐怖网站电影在线 浏览:207
webbrowser密码框 浏览:720
大奶按摩电影 浏览:126
nios2uclinux文件系统 浏览:228
拍摄指南by制造机txt下载 浏览:187
中东一个小男孩的电影 浏览:41
最好看的机甲小说 浏览:495
小孩第一次进电影院英文翻译 浏览:729
ios获取项目文件路径 浏览:100

友情链接