導航:首頁 > 編程語言 > 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製作注冊頁面相關的資料

熱點內容
d4252用什麼軟體編程 瀏覽:35
大學生如何參與大數據 瀏覽:779
autocad3維教程 瀏覽:2
港澳台版本有什麼區別 瀏覽:263
java四個月能學到什麼 瀏覽:46
開發板和linux文件 瀏覽:202
appstore外國帳號怎麼看預約游戲 瀏覽:137
有什麼免費加速網站的cdn 瀏覽:781
哪個文件存在最安全 瀏覽:199
淘寶導航欄分割線代碼 瀏覽:271
win10開不了機按f8沒用 瀏覽:12
河南營銷網站推廣多少錢 瀏覽:135
華為暢享6手機文件管理 瀏覽:939
linux驅動環境 瀏覽:893
ae用什麼打開文件 瀏覽:877
湖南嶽陽大數據中心 瀏覽:710
DSP大數據公司 瀏覽:510
win10檢測不到u盤啟動 瀏覽:941
電腦文件怎麼重命名文件 瀏覽:507
哪個協議用來傳輸文件協議 瀏覽:61

友情鏈接