当前位置:首页 > 代码 > 正文

jsp登陆页面代码(jsp编写用户的登录页面)

admin 发布:2022-12-19 19:55 174


今天给各位分享jsp登陆页面代码的知识,其中也会对jsp编写用户的登录页面进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

jsp 登录代码解释

%

//获取从表单提交过来的参数uid

String uid = request.getParameter("uid") ;

//获取从表单提交过来的参数pwd

String pwd = request.getParameter("pwd") ;

//获取从表单提交过来的参数author

String author = request.getParameter("author") ;

//把uid设置到session里

session.setAttribute("uid",uid) ;

//调用setUid方法,设置该对象uid属性的值为从表单提交过来的uid值

login.setUid(uid) ;

//调用setUid方法,设置该对象pwd属性的值为从表单提交过来的pwd值

login.setPwd(pwd) ;

//调用setUid方法,设置该对象author属性的值为从表单提交过来的author值

login.setAuthor(author) ;

//输出login对象的uid的值

out.print(login.getUid());

//调用CheckUser方法检查用户名和密码是否正确

if(login.CheckUser()){

//假如CheckUser方法的返回值为true,即用户名和密码正确,

//则把字符串"您登录成功"设置到session中去

session.setAttribute("session","您登录成功");

//登录成功,跳转到success.jsp页面

response.sendRedirect("success.jsp") ;

}

else{

//如果用户名或者密码错误,则把字符串"登录失败"设置到session中去

session.setAttribute("session","登录失败!");

//登录失败,跳转到failure.jsp页面

response.sendRedirect("failure.jsp") ;

}

%

JSP编写一个登陆界面

1、首先准备Dreamweaver8软件,解压安装。如下图所示:这件点击安装程序,然后输入序列号就可以了。

2、在安装软件时候,我们可以看到是否关联【jsp文件】。

3、安装好了软件以后,我们打开Dreamweaver8软件。点击菜单上的【文件】——【新建】。

4、弹出【新建文档】——【动态页】——【jsp】——【创建】。

5、点击【拆分】,在【body】标签下面输入:%     out.println("Hello World!");     %。

6、然后按快捷键【ctrl+s】保存jsp文件。保存类型jps;。

编写用户注册于登录的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

用jsp编写一个很简单的登陆页面

login.JSP

注: 由于时间仓促,程序可能有细小的问题!但绝对可以满足你的需要了!如果你知道JSP什么原理;那么小的问题不是什么问题了! 共同学习~~~

%@ page contentType = "text/html;charset=GB2312" %

%@ page import = "java.sql.*" %

html

head

title/title

/head

body bgcolor=LightBlue

div align="center"

br

H1欢迎光临企业办公平台/H1

form name="form1" method="post" action="" target="_self"

table width="90%"

tr

td width="50%" height="30" align="right"用户名:/td

td width="50%" height="30" align="left" input type="text" name="UserName"/td

/tr

tr

td width="50%" height="30" align="right"密码:/td

td width="50%" height="30" align="left" input type="password" name="UserPassword"/td

/tr

td width="100%" height="40" align="center" colspan="2"

input type="submit" name="sub" value="登录"  

/td

/tr

/table

/form

/div

% try

{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection conn=DriverManager.getConnection("jdbc:odbc:a","root","database1");

Statement stmt = conn.createStatement(

ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSet rs = null;

String name =new String(request.getParameter("

UserName").getBytes(“8859_1”));

String passwd =new String(request.getParameter("

UserPassword").getBytes(“8859_1”));

if(String_sql==null)

{

out.println("登陆名不可以为空");

out.println(“HR”);

}

else{

String_sql="select * from student where name ="+name+" and password="+psword+;

rs=stmt.executeQuery(String_sql)

while(rs.next())

{ out.println("登陆成功!");

out.println("您的用户名是:"+name)

out.println("您的密码是:"+password);

rs.close();

stmt.close();

conn.close();}

}

Catch( Exception e )

{out.println(“font color=red size=5B”);

out.println(“出错了!”);

out.println(“/B/font”);

}%

/body

/html

用JAVA/JSP做一个登陆页面

登录判断的页面代码%@ page contentType="text/html; charset=gb2312"%%@ page import="java.sql.*"%%@ page import="java.util.*"%%@ include file="conn.jsp"%%request.setCharacterEncoding("gb2312");Statement stat=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String name=request.getParameter("name");String password=request.getParameter("password");ResultSet rs=stat.executeQuery("select * from sjb where name='"+name+"'and pass='"+password+"'");%%if(rs.next()){%%String shenfen=rs.getString(6);session.setAttribute("name",name);response.sendRedirect("index1.jsp");}else{out.print("帐号密码输入错误");%a href="index1.jsp"点击返回/a%}%登录输入时的代码form action="login.jsp" method="post" name="form1" class="STYLE1" id="form1" br / 帐号 label input name="name" type="text" id="name" tabindex="1" size="13" maxlength="13" / /label A href="regedit.jsp"注册/Abr / 密码 label input name="password" type="password" id="password" size="13" maxlength="13" / /label a href="forget.jsp"忘记/abr / br / label input type="submit" name="Submit" value="确定" / /label label input type="reset" name="Submit2" value="重填" / /label br / br / /form

§哇凉De心№ 回答采纳率:30.0% 2008-10-23 19:29 检举

table width="100%" border="0" cellpadding="0" cellspacing="0" form name=myForm method=post action="%=appPath%/memberLoginDispather.do?method=doMemberLogin" tr td用户名/td tdinput name="username" type="text" class="input" size="23" maxlength="20" value="" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"//td /tr tr td密  码/td td input name="password" type="password" class="input" size="23" maxlength="20" value=""//td /tr tr td colspan="2" align="center" input type="Submit" value="登陆"class=inputtxt input type="reset" value="重置" class=inputtxt /td /tr form /table

有什么问题可以问我

关于jsp登陆页面代码和jsp编写用户的登录页面的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/21671.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载