當前位置:首頁 » 注冊證書 » 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