当前位置:首页 » 注册证书 » jsp登陆注册

jsp登陆注册

发布时间: 2020-11-29 18:16:48

㈠ 用eclipse中的JSP做一个登录界面和注册页面,登录界面要输入帐号密码,注册页面可注册,注册之后可登录

帐号密码你可以用javascript判断啊,然后再注册嘛,你得到输入的账号和密码的值,然后在后台写入添加用户的方法,即可啊。注册成功后,跳转到登陆页面,获取登陆页面上输入的值,拿到数据库中查询,判断是否存在,存在即可登陆。

㈡ jsp 登陆和注册问题

用js脚本作登陆或者注册验证啊 ,
function checkdata() {
var ssn=form.username.value;

㈢ 求jsp简单的登陆跳转注册页面

登陆页:
<%@ page language="java" pageEncoding="GB18030"%>
<head>
</head>
<body>
<form action="login_success.jsp" method="post">
用户名:
<input type="text" name="username" />
<br>
密 码
<input type="password" name="password" />
<br>
<input type="submit" name="Submit" value="登陆" />
<input type="reset" name="cancelButton" value="取消" />
</form>
</body>

登陆成功页:
<%@ page language="java" pageEncoding="GB18030"%>
<head>
</head>
<body>
<%
String name = request.getParameter("username");
String pwd = request.getParameter("password");

if ("hello".equals(name.trim()) && "word".equals(pwd.trim())) {
%>
<h1>
登陆成功:
<%=name%></h1>

<%
} else {
%>
<h1>
登录失败:
</h1>
<br>
三秒后跳到注册页面:
<%
response.setHeader("refresh", "3;url=regiest.jsp");
%>
<%
}
%>

</body>

注册页:
<%@ page language="java" pageEncoding="GB18030"%>
<head>
</head>
<body>
<form action="regiest_success.jsp" method="post">
用户名:
<input type="text" name="username" />
<br>
密 码
<input type="password" name="password" />
<br>
确认密 码
<input type="password" name="password2" />
<br>
<input type="submit" name="Submit" value="注册" />
<input type="reset" name="cancelButton" value="取消" />
</form>
</body>

注册成功页:

<%@ page language="java" pageEncoding="GB18030"%>
<head>
</head>
<body>
<%
String name = request.getParameter("username");
String pwd = request.getParameter("password");
String pwd2 = request.getParameter("password2");
if (null == name || "".equals(name)) {
out.print("用户名不能为空!!");

return;
}

if (null == pwd || "".equals(pwd)) {
out.print("密码不能为空!!");
return;
}
if (null == pwd2 || "".equals(pwd2)) {
out.print("确认密码不能为空!!");
return;
}

if (!pwd.equals(pwd2)) {
out.println("两次密码不正确!");
return;
}

response.sendRedirect("login.jsp");
%>
</body>

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

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

㈤ jsp+ajax实现 注册、登录功能。

一、处理ajax请求的jsp文件:auto.jsp , 你按照这样就没问题了
<%@ page contentType="text/html; charset=gb2312" %>

<%
//设置输出信息的格式及字符集
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control","no-cache");
out.println("<response>");

for(int i=0;i<2;i++){
out.println("<name>"+(int)(Math.random()*10)+
"型笔记本</name>");
out.println("<count>" +(int)(Math.random()*100)+ "</count>");
}
out.println("</response>");
out.close();
%>

二、发送ajax请求的html文件:autoRefresh.html

<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<script language="javascript">

var XMLHttpReq;
//创建XMLHttpRequest对象
function createXMLHttpRequest() {
if(window.XMLHttpRequest) { //Mozilla 浏览器
XMLHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE浏览器
try {
XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}
//发送请求函数
function sendRequest() {
createXMLHttpRequest();
var url = "auto.jsp";
XMLHttpReq.open("GET", url, true);
XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
XMLHttpReq.send(null); // 发送请求
}
// 处理返回信息函数
function processResponse() {
if (XMLHttpReq.readyState == 4) { // 判断对象状态
if (XMLHttpReq.status == 200) { // 信息已经成功返回,开始处理信息
DisplayHot();
setTimeout("sendRequest()", 1000);
} else { //页面不正常
window.alert("您所请求的页面有异常。");
}
}
}
function DisplayHot() {
var name = XMLHttpReq.responseXML.getElementsByTagName("name")[0].firstChild.nodeValue;
var count = XMLHttpReq.responseXML.getElementsByTagName("count")[0].firstChild.nodeValue;
document.getElementById("proct").innerHTML = name;
document.getElementById("count").innerHTML = count;
}

</script>
<body onload =sendRequest()>
<table style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width=200 bgColor=#f5efe7 border=0>

<TR>
<TD align=middle bgColor=#dbc2b0 height=19 colspan="2"><B>正在热卖的笔记本</B> </TD>
</TR>
<tr>
<td height="20"> 型号:</td>
<td height="20" id="proct"> </td>
</tr>
<tr>
<td height="20"> 销售数量:</td>
<td height="20" id="count"> </td>
</tr>
</body>
</table>

㈥ jsp做登录,注册页面 数据库

jsp登录注册页面都需要查询和插入数据库的,还要检查注册信息存不存在。
完整例子如下:

用户信息的bean:

package chen;

public class UserBean
{
private String userid;
private String password;

public void setUserId(String userid)
{
this.userid=userid;
}
public void setPassword(String password)

{
this.password=password;
}
public String getUserId()
{
return this.userid;
}
public String getPassword()
{
return this.password;
}

}

提交数据库的bean:
package chen;
import com.mysql.jdbc.Driver;
import java.sql.*;
public class UserRegister
{
private UserBean userBean;
private Connection con;
//获得数据库连接。
public UserRegister()
{

String url="jdbc:mysql://localhost/"+"chao"+"?user="+"root"+"&password="+"850629";

try
{

Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url);
}
catch(Exception e)
{
e.printStackTrace();
}

}
//设置待注册的用户信息。
public void setUserBean(UserBean userBean)
{
this.userBean=userBean;
}
//进行注册
public void regist() throws Exception
{
String reg="insert into userinfo(userid,password) values(?,?)";

try
{
PreparedStatement pstmt=con.prepareStatement(reg);
pstmt.setString(1,userBean.getUserId());
pstmt.setString(2,userBean.getPassword());
pstmt.executeUpdate();
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}

}
}
提交注册数据进入数据库:

<%@ page contentType="text/html;charset=gb2312" pageEncoding="gb2312"
import="chen.*" %>
<jsp:useBean id="userBean" class="chen.UserBean" scope="request">
<jsp:setProperty name="userBean" property="*"/>
</jsp:useBean>
<jsp:useBean id="regist" class="chen.UserRegister" scope="request"/>
<html>
<head>
<title> 用户信息注册页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>

<%
String userid =request.getParameter("userid");
String password = request.getParameter("password");
userBean.setUserId(userid);

userBean.setPassword(password);
System.out.println(userid+password);
%>
<% try{
regist.setUserBean(userBean);
out.println(userid);
regist.regist();
out.println("注册成功");}
catch(Exception e){
out.println(e.getMessage());
}
%>
<br>
<a href="login.jsp">返回</a>
</body>
</html>

登陆验证页面:

<%@page import="java.sql.*" contentType="text/html;charset=GB2312" %>
<%@page import="java.util.*"%>
<%
String userid1=new String(request.getParameter("userid"));
String password1=new String(request.getParameter("password"));

Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/chao","root","850629");
Statement stmt=con.createStatement();
String sql="select * from userinfo where userid='"+userid1+"';";
ResultSet rs=stmt.executeQuery(sql);
if(rs.next())
{String password=new String(rs.getString("password"));
if(password.equals(password1))
{session.setAttribute("userid1",userid1);
response.sendRedirect("sucess.jsp");
}
else
{response.sendRedirect("login.jsp");
}
}
else
{response.sendRedirect("login.jsp");
}
%>
登陆页面:

<%@ page contentType="text/html; charset=gb2312" %>
<html>
<body>
<form method="get" action="checklogin.jsp">
<table>
<tr><td> 输入用户名:</td>
<td><input type=text name=userid ></td>
</tr>
<tr><td>输入密码:</td>
<td><input type=password name=password></td>
</tr>
<tr><td><input type=submit value=确认>
</td></tr>
</table>
</form>
<form action="register.jsp">
<input type=submit value=注册>
</form>
</body>
</html>

注册页面:

<%@page contentType="text/html; charset=gb2312" language="java" import="java.util.*,java.io.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<center>
<h1>注册新用户</h1>
<form action="adser.jsp" method=post>
<table border="1" bgcolor="#0099CC">
<tr>
<td> 用户名:
<input type="text" name="userid">
</td>
</tr>
<tr valign="middle">
<td> 密码:
<input type="password" name="password" readonly>
</td>
</tr>
<tr>
<td>
<input type=submit value=提交>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

登陆成功页面:

<%@page import="java.util.*" contentType="text/html; charset=gb2312" %>
<%@include file="trans.jsp"%>
<html>
<head>
<title>
sucess
</title>
</head>
<body bgcolor="#ffffff">
<h1>
登录成功,欢迎您!

</h1><%=trans(session.getAttribute("userid1"))%>
</body>
</html>

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

下面的html实现了你所说的功能,使用的时候把代码放到jsp页面中效果是一样的:
<!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页面的全部程序代码

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连接数据库实现登录注册

jsp登录连接数据库源代码
果你是直接从jsp
跳转到jsp
的话
%
request.setcharacterencoding("gbk");
string
uname=request.getparameter("username");
//获得登录页面的登录名
string
upass=request.getparameter("userpass");
//获得登录页面的登录密码
userinfo
u=new
userinfo();
boolean
result=
u.checklogin(uname,upass);
//根据登录名和密码验证是否存在
if(result==true){
%
欢迎你%=
uname%
%}else{%
登录失败!
%}
%
/**
用户信息数据处理类
*/
public
class
userinfo
extends
database{
private
connection
con;
private
preparedstatement
titlesquery;
private
resultset
res;
//根据登录名和密码验证是否存在
public
boolean
checklogin(string
uname,string
upass){
boolean
result=false;
try{
con=this.getconnection();
titlesquery=con.preparestatement("
select
upass
from
userinfo
where
uname
=
?
");
titlesquery.setstring(1,
uname);
res=titlesquery.executequery();
while(res.next()){
if
(res.getstring("upass").equals(upass))
{
result=true;
}
}
}catch(sqlexception
exception){
exception.printstacktrace();
}finally{
this.closeall(con,
titlesquery,
res);
}
return
result;
}
}
喜居宝地千年旺
福照家门万事兴
喜迎新春

㈩ jsp做网站怎么实现用户登录和注册

首先dreamwaver只是设计页面。。。。然后你想开发用jsp做网站,也就是想把逻辑处理代码都写在jsp页面中,这样你要有个jdbc,有一个驱动,驱动是用来连接数据库的,而jdbc是用来操作的,首先,你需要新建四个页面这5个页面,一个是用来注册和登录的。(如果只有用户名,密码两个字段的话就可以,不然,注册和登录要分开),第二个页面:对数据的处理页面,在这个页面中,你需要从第一个页面中获取值,一般是用的request来获取属性,然后用jdbc中的方法,将数据写入到数据库中,这个就是注册逻辑页面,然后跳转到,注册成功请登录,也就是第四个页面。第三个页面是登录逻辑处理页面,通过从第一个页面中传来的值,查询数据库信息,对比密码是否相同,如果相同,则跳转到登录成功,如果不同,则跳转到登录页面,具体代码,很简单,我就不写了相信流程给你说清楚了,你就有大概的思路了哦

热点内容
美发店认证 发布:2021-03-16 21:43:38 浏览:443
物业纠纷原因 发布:2021-03-16 21:42:46 浏览:474
全国著名不孕不育医院 发布:2021-03-16 21:42:24 浏览:679
知名明星确诊 发布:2021-03-16 21:42:04 浏览:14
ipad大专有用吗 发布:2021-03-16 21:40:58 浏览:670
公务员协议班值得吗 发布:2021-03-16 21:40:00 浏览:21
知名书店品牌 发布:2021-03-16 21:39:09 浏览:949
q雷授权码在哪里买 发布:2021-03-16 21:38:44 浏览:852
图书天猫转让 发布:2021-03-16 21:38:26 浏览:707
宝宝水杯品牌 发布:2021-03-16 21:35:56 浏览:837