java注册jsp代码,jsp登录注册代码

java 我做了简单的用户注册系统,现在我要把用户注册的信息显示在jsp页面上,该怎么写?

//这句是用response跳转到你要跳转的页面,并将值usename传递过去,

创新互联建站专业为企业提供江安网站建设、江安做网站、江安网站设计、江安网站制作等企业网站建设、网页设计与制作、江安企业网站模板建站服务,十载江安做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

response.sendRedirect("你要跳转的页面.jsp?usename="+usename);

//在你要跳转的页面,就用request获取就行了。

h1%=request.getParameter("usename")%!欢迎你的登陆!/h1

具体的话,应该是这么写,其实也还有其他的方法,我就只记得这一个了,希望能帮到你

java 设计注册用户个人信息的JSP页面

%@ page language="java" import="java.util.*" pageEncoding="gbk"%

%

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注册啦../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"

--

link href="../css/rayx.css" type="text/css" rel="stylesheet"

title填写注册信息/title

script language="javascript"

!--

function selectCity(){

if(RegInfoPost.state.value=="上海"){

RegInfoPost.city.value="上海";

}

else if(RegInfoPost.state.value=="天津"){

RegInfoPost.city.value="天津";

}

else if(RegInfoPost.state.value=="北京"){

RegInfoPost.city.value="北京";

}

else if(RegInfoPost.state.value=="重庆"){

RegInfoPost.city.value="重庆";

}

else if(RegInfoPost.state.value=="中国香港"){

RegInfoPost.city.value="中国香港";

}

else if(RegInfoPost.state.value=="中国澳门"){

RegInfoPost.city.value="中国澳门";

}

else{

RegInfoPost.city.value="";

}

}

function checkCity(){

if(RegInfoPost.city.value=="北京"){

RegInfoPost.address.focus();

}

if(RegInfoPost.city.value=="上海"){

RegInfoPost.address.focus();

}

if(RegInfoPost.city.value=="天津"){

RegInfoPost.address.focus();

}

if(RegInfoPost.city.value=="重庆"){

RegInfoPost.address.focus();

}

if(RegInfoPost.city.value=="中国香港"){

RegInfoPost.address.focus();

}

if(RegInfoPost.city.value=="中国澳门"){

RegInfoPost.address.focus();

}

}

--

/script

script language="javascript"

!--

function onSubmit(){

%//检查姓名%

if(RegInfoPost.realName.value==""){

alert("请填写姓名!");

RegInfoPost.realName.focus();

return false;

}

%//检查身份证%

else if(RegInfoPost.identityCard.value==""){

alert("请填写身份证号码!");

RegInfoPost.identityCard.focus();

return false;

}

%//检查身份证的格式是否合法%

else if(chkid(RegInfoPost.identityCard.value)==0){

alert("您填写的身份证号码不是合法的身份证号码!");

RegInfoPost.identityCard.focus();

return false;

}

%//检查邮政编码%

else if(RegInfoPost.zip.value==""){

alert("请填写邮政编码!");

RegInfoPost.zip.focus();

return false;

}

%//检查邮政编码是否含有空格%

else if(chkspc(RegInfoPost.zip.value)!=1){

alert("邮政编码含有空格!");

RegInfoPost.zip.focus();

return false;

}

%//检查邮政编码是否符合格式%

else if(checkZip(RegInfoPost.zip.value)==0){

alert("不是中国的邮政编码,或者邮政编码有非法字符!");

RegInfoPost.zip.focus();

return false;

}

%//检查省市自治区%

else if(RegInfoPost.state.value=="default"){

alert("请选择省市自治区!");

RegInfoPost.state.focus();

return false;

}

%//检查城市%

else if(RegInfoPost.city.value==""){

alert("请填写城市!");

RegInfoPost.city.focus();

return false;

}

%//检查地址%

else if(RegInfoPost.address.value==""){

alert("请填写地址!");

RegInfoPost.address.focus();

return false;

}

%//检查主要联系电话%

else if(RegInfoPost.phone.value==""){

alert("请填写主要联系电话!");

RegInfoPost.phone.focus();

return false;

}

%//检查生日(年)%

else if(RegInfoPost.birthdayYear.value==""){

alert("请填写您的生日!");

RegInfoPost.birthdayYear.focus();

return false;

}

%//检查出生年份有效性%

else if(chkYear(RegInfoPost.birthdayYear.value)==0){

alert("您的生日不符合格式!");

RegInfoPost.birthdayYear.focus();

return false;

}

%//检查生日(月)%

else if(RegInfoPost.birthdayMonth.value=="default"){

alert("请填写您的生日!");

RegInfoPost.birthdayMonth.focus();

return false;

}

%//检查生日(日)%

else if(RegInfoPost.birthdayDay.value=="default"){

alert("请填写您的生日!");

RegInfoPost.birthdayDay.focus();

return false;

}

%//检查电子邮件%

else if(RegInfoPost.email.value==""){

alert("请填写您的电子邮件地址!");

RegInfoPost.email.focus();

return false;

}

%//检查电子邮件是否合法%

else if(chkemail(RegInfoPost.email.value)!=1){

alert("电子邮件地址不符合格式!");

RegInfoPost.email.focus();

return false;

}

%//检查用于确认的电子邮件地址%

else if(RegInfoPost.email.value!=RegInfoPost.email2.value){

alert("请确认您的电子邮件填写的准确无误!");

RegInfoPost.email2.focus();

return false;

}

else{

%

session.setAttribute("frompage","reg.jsp");

%

RegInfoPost.submit();

}

}

%

//函数名:chkspc

//功能介绍:检查是否含有空格

//参数说明:要检查的字符串

//返回值:0:有空格 1:没有空格 2:有空格

%

function chkspc(a){

var i=a.length;

var j = 0;

var k = 0;

while(ki){

if(a.charAt(k)!=" "){

j = j+1;

}

k = k+1;

}

if(j==0){

return 0;

}

if(i!=j){

return 2;

}

else{

return 1;

}

}

%

//函数名:checkNum

//功能介绍:检查是否为数字

//参数说明:要检查的数字

//返回值:0:不是数字 1:是数字

%

function checkNum(num){

var i,j,strTemp;

strTemp="0123456789";

if(num.length==0)

return 0;

for(i=0;inum.length;i++){

j=strTemp.indexOf(num.charAt(i));

if (j==-1){

return 0;

}

}

return 1;

}

%

//函数名:chkid

//功能介绍:检查身份证

//参数说明:要检查的字符串

//返回值:0:不合格 1:合格

%

function chkid(id){

if(id.length!=15 id.length!=18){

return 0;

}

else if(chkspc(id)!=1){

return 0;

}

else if(checkNum(id)==0){

return 0;

}

else

return 1;

}

%

//函数名:checkZip

//功能介绍:检查是否为有效的邮政编码

//参数说明:要检查的数字

//返回值:1为是有效的,0为不是有效的

%

function checkZip(zip){

if(zip.length!=6){

return 0;

}

else if(checkNum(zip)==0){

return 0;

}

}

%

//检查电子邮件是否合法

//函数名:chkemail

//参数说明:要检查的字符串

//返回值:1:是

%

function chkemail(a){

var i=a.length;

var temp = a.indexOf('@');

var tempd = a.indexOf('.');

if(temp 1) {

if((i-temp) 3){

if((i-tempd)0){

return 1;

}

}

}

}

%

//检查出生年份是否符合规定

//返回值:0:不正确 1:正确

%

function chkYear(year){

if(year.length!=4)

return 0;

if(checkNum(year)==0)

return 0;

else if(chkspc(year)!=1)

return 0;

else

return 1;

}

--

/script

script language="javascript"

var xmlHttp;

function createXMLHttpRequest(){

if(window.ActiveXObject){

xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}else if(window.XMLHttpRequest){

xmlHttp = new XMLHttpRequest();

}

}

function startRequest(){

createXMLHttpRequest();

xmlHttp.onreadystatechange = handleStateChange;

var uname = document.getElementById("userName").value;

xmlHttp.open("POST","RegAjax?name="+uname,true);

xmlHttp.send(null);

}

function handleStateChange(){

if(xmlHttp.readyState==4){

if(xmlHttp.status==200){

if("t"==(xmlHttp.responseText))

alert("用户名已被占用");

}

}

}

/script

/head

body

%

if("OK".equals(request.getSession().getAttribute("reginfo"))){

response.setHeader("refresh","2;URL=../index.jsp");

%

注册成功啦。br

两秒钟后返回首页,如果没有返回br

请点这里a href="../index.jsp"返回/a主页

%

}else{

if(request.getSession().getAttribute("reginfo")!=null){

%

center%=(String)request.getSession().getAttribute("reginfo") %/center

%} %

form name="RegInfoPost" method="post" action="reg.do"

table width="615" height="617" border="0" align="center"

tra href="./index.jsp"点这返回首页/a

td colspan="4"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr

td colspan="4"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr

td width="150" height="30" valign="top"!--DWLayoutEmptyCell-- /td

td width="339" valign="middle"

span class="style2"strong用户帐号:/strong/span

input name="userName" type="text" class="item_table" id="userName" maxlength="16" OnBlur="startRequest()"

span class="error"*(6-16个字符)/span /td

td width="126" valign="middle"

/td

/tr

tr

td /td

td valign="middle"strong用户密码:/strong input name="password" type="password" class="item_table" id="password" maxlength="16"

span class="error"*(6-16个字符) /span /td

td /td

/tr

tr

td height="30" /td

td valign="middle" strong确认密码:/strong input name="password2" type="password" class="item_table" id="password2" maxlength="16"

span class="error"*(请确认密码)/span /td

td /td

/tr

tr align="center" valign="middle"

td height="30" colspan="3" valign="middle"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr align="center" valign="middle"

td height="20" colspan="3"span class="error"密码保护(在您忘记密码时,将通过以下问题来重新获得您的密码)/span/td

/tr

tr align="center" valign="middle"

td height="30" /td

td colspan="2" align="left" valign="middle"strong密码提示问题:/strong input name="question" type="text" class="item_table" id="question" maxlength="20"

span class="error"*(不超过20个字符)/span /td

/tr

tr align="center" valign="middle"

td height="30" /td

td colspan="2" align="left" valign="middle"strong密码提示答案:/strong input name="answer" type="text" class="item_table" id="answer" maxlength="10"

span class="error"*(不超过10个字符)/span /td

/tr

tr

td height="14" colspan="2" valign="top"strong姓名/strongfont color="#ff0000"span class="error"*/span/td

td colspan="2" valign="top"strong身份证号码/strongfont color="#ff0000"span class="error"*/span/td

/tr

tr

td height="18" colspan="2" valign="top"

input name="realName" type="text" id="realname" /td

td colspan="2" valign="top"input name="identityCard" type="text" id="identityCard" size="18" maxlength="18"/td

/tr

tr

td width="116" height="14" /td

td width="185" /td

td width="127" /td

td width="169" /td

/tr

tr

tdstrong国家或地区/strongfont color="#ff0000"span class="error"*/span/td

tdstrong邮政编码/strongfont color="#ff0000"span class="error"*/span/td

tdstrong省市自治区/strongfont color="#ff0000"span class="error"*/span/td

tdstrong城市/strongfont color="#ff0000"span class="error"*/span/td

/tr

tr

td

select name="country" id="country"

option selected中国/option

option中国香港/option

option中国澳门/option

option中国台湾/option

/select

/td

td

input name="zip" type="text" id="zip"

/td

td

select name="state" id="state" onclick="selectCity()"

option value="default" selected name="value" isCity="false"选择省市自治区/option

option name="value" value="北京" isCity="true"北京/option

option name="value" value="上海" isCity="true"上海/option

option name="value" value="天津" isCity="true"天津/option

option name="value" value="重庆" isCity="true"重庆/option

option name="value" value="安徽省" isCity="false"安徽省/option

option name="value" value="福建省" isCity="false"福建省/option

option name="value" value="甘肃省" isCity="false"甘肃省/option

option name="value" value="广东省" isCity="false"广东省/option

option name="value" value="广西壮族自治区" isCity="false"广西壮族自治区/option

option name="value" value="贵州省" isCity="false"贵州省/option

option name="value" value="海南省" isCity="false"海南省/option

option name="value" value="河北省" isCity="false"河北省/option

option name="value" value="河南省" isCity="false"河南省/option

option name="value" value="黑龙江省" isCity="false"黑龙江省/option

option name="value" value="湖北省" isCity="false"湖北省/option

option name="value" value="湖南省" isCity="false"湖南省/option

option name="value" value="吉林省" isCity="false"吉林省/option

option name="value" value="江苏省" isCity="false"江苏省/option

option name="value" value="江西省" isCity="false"江西省/option

option name="value" value="辽宁省" isCity="false"辽宁省/option

option name="value" value="内蒙古自治区" isCity="false"内蒙古自治区/option

option name="value" value="宁夏回族自治区" isCity="false"宁夏回族自治区/option

option name="value" value="青海省" isCity="false"青海省/option

option name="value" value="山东省" isCity="false"山东省/option

option name="value" value="山西省" isCity="false"山西省/option

option name="value" value="陕西省" isCity="false"陕西省/option

option name="value" value="四川省" isCity="false"四川省/option

option name="value" value="台湾省" isCity="false"台湾省/option

option name="value" value="西藏自治区" isCity="false"西藏自治区/option

option name="value" value="新疆维吾尔自治区" isCity="false"新疆维吾尔自治区/option

option name="value" value="云南省" isCity="false"云南省/option

option name="value" value="浙江省" isCity="false"浙江省/option

option name="value" value="中国香港" isCity="true"中国香港/option

option name="value" value="中国澳门" isCity="true"中国澳门/option

/select

/td

td

input name="city" type="text" id="city" onfocus="checkCity()"

/td

/tr

tr

td colspan="4" /td

/tr

tr

td colspan="4"strong送货地址/strongfont color="#ff0000"span class="error"*/span/td

/tr

tr

td colspan="4"

input name="address" type="text" id="address" size="41"

/td

/tr

tr

td colspan="4" /td

/tr

tr

td colspan="2"strong主要联系电话/strongfont color="#ff0000"span class="error"*/span/td

/tr

tr

td colspan="2"

input name="phone" type="text" id="phone"

/td

/tr

tr

td colspan="4" /td

/tr

tr

td colspan="4"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr

td colspan="4"span class="error"请填写真实有效的电子邮件地址/span/td

/tr

tr

td colspan="4"strong电子邮件地址font color="#ff0000"/strongspan class="error"*/span/td

/tr

tr

td colspan="4"

input name="email" type="text" id="email" size="40" /td

/tr

tr

td colspan="4" span class="style2"范例:/spanspan class="style3" myname@hotmail.com/span/td

/tr

tr

td colspan="4" strong请再一次输入您的电子邮件地址/strongfont color="#ff0000"span class="error"*/span/td

/tr

tr

td colspan="4"

input name="email2" type="text" id="email2" size="40" /td

/tr

tr

td colspan="4"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr

td colspan="4" /td

/tr

tr

td /tdtd colspan="2"div align="center"strong接受用户协议/strong/div/td

/tr

tr

td height="87" colspan="4"div align="center"

textarea name="textarea" cols="70" rows="15" wrap="VIRTUAL" 本网站仅为威迅教育交流学习之用,您必须无条件接受以下条件方可继续注册。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播下列信息:

(一)煽动抗拒、破坏宪法和法律、行政法规实施的;

(二)煽动颠覆国家政权,推翻社会主义制度的;

(三)煽动分裂国家、破坏国家统一的;

(四)煽动民族仇恨、民族歧视,破坏民族团结的;

(五)捏造或者歪曲事实,散布谣言,扰乱社会秩序的;

(六)宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪的;

(七)公然侮辱他人或者捏造事实诽谤他人的,或者进行其他恶意攻击的;

(八)损害国家机关信誉的;

(九)其他违反宪法和法律行政法规的;

(十)进行商业广告行为的。

二、互相尊重,对自己的言论和行为负责。 /textarea

/div/td

/tr

tr

td colspan="4"div align="center"strong当通过点击”注册“按钮即表示我已无条件接受以上协议/strong/div/td

/tr

tr

td colspan="4"hr color="#cccccc" noshade="yes" size="1"/td

/tr

tr

td colspan="4"div align="center"

input type="submit" name="Submit" value="注册" onClick="return onSubmit()"

input type="reset" name="Reset" value="重置"

/div/td

/tr

tr

td height="46" colspan="4" /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

tdinput 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

当前文章:java注册jsp代码,jsp登录注册代码
标题来源:https://www.cdcxhl.com/article24/dsehdce.html

成都网站建设公司_创新互联,为您提供移动网站建设搜索引擎优化微信小程序商城网站网站内链标签优化

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站制作