Jsp学生信息管理系统登录验证全代码.docx

上传人:b****1 文档编号:478624 上传时间:2023-04-29 格式:DOCX 页数:12 大小:18.42KB
下载 相关 举报
Jsp学生信息管理系统登录验证全代码.docx_第1页
第1页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第2页
第2页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第3页
第3页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第4页
第4页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第5页
第5页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第6页
第6页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第7页
第7页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第8页
第8页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第9页
第9页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第10页
第10页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第11页
第11页 / 共12页
Jsp学生信息管理系统登录验证全代码.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Jsp学生信息管理系统登录验证全代码.docx

《Jsp学生信息管理系统登录验证全代码.docx》由会员分享,可在线阅读,更多相关《Jsp学生信息管理系统登录验证全代码.docx(12页珍藏版)》请在冰点文库上搜索。

Jsp学生信息管理系统登录验证全代码.docx

Jsp学生信息管理系统登录验证全代码

1.jsp登录界面Login.jsp

<%@pagelanguage="java”contentType="text/html;charset=UTF—8”

pageEncoding=”UTF-8”%〉

〈title〉用户登录界面〈/title>

〈/head>

〈bodybgcolor=”blue”〉

〈marqueedirection=”right”onmouseover=”stop()"onmouseout="start()”style=”font—family:

楷体”>

〈p>学生信息信息管理系统〈/font>〈/p〉

〈tr〉

〈tr〉

〈tdcolspan=6>〈fontsize=2〉

style="FILTER:

revealTrans(Duration=1,Transition=23);WIDTH:

100%;HEIGHT:

162px”〉〈/div〉

〈/font〉〈/td〉

〈/tr〉

〈tdalign=centerSTYLE=’cursor:

hand’〉〈fontsize=2>

〈divclass=”b2bbutton"id="bt0”

onclick="javascript:

showPage(0);clearTimeout(theTimer);theTimer=setTimeout('turnPage()’,speed);checkBt();"〉1〈/div>

〈/font〉〈/td>

〈tdalign=centerSTYLE=’cursor:

hand'〉

〈divclass="b2bbutton"id=”bt1"

onclick=”javascript:

showPage

(1);clearTimeout(theTimer);theTimer=setTimeout(’turnPage()',speed);checkBt();”>2

〈/font>〈/td〉

hand’〉〈fontsize=2>

onclick="javascript:

showPage

(2);clearTimeout(theTimer);theTimer=setTimeout('turnPage()’,speed);checkBt();”>3〈/div〉

〈/font〉

〈tdalign=centerSTYLE='cursor:

hand’>〈fontsize=2〉

〈divclass=”b2bbutton”id="bt3"

onclick="javascript:

showPage(3);clearTimeout(theTimer);theTimer=setTimeout('turnPage()’,speed);checkBt();">4〈/div>

〈/font〉〈/td>

hand’>〈fontsize=2〉

onclick=”javascript:

showPage(4);clearTimeout(theTimer);theTimer=setTimeout('turnPage()',speed);checkBt();"〉5

〈/font〉

hand'>

〈divclass=”b2bbutton"id=”bt5"

onclick=”javascript:

showPage(5);clearTimeout(theTimer);theTimer=setTimeout(’turnPage()',speed);checkBt();">6

〈/font>〈/td>

〈scriptlanguage=”javascript"〉

b2bStr=newArray();

b2bStr[0]="〈divstyle='float:

left;width:

100%;overflow:

hidden;’〉〈ahref=1。

giftarget=_blank〉

gifwidth=214pxheight=145pxborder=0〉〈/a〉〈br〉”;

b2bStr[1]="

left;width:

100%;overflow:

hidden;’〉〈ahref=2.giftarget=_blank>〈imgsrc=2。

gifwidth=214pxheight=145pxborder=0>〈atarget=_blanktitle=太阳岛公园湖光山色href=2.gif〉太阳岛公园湖光山色〈/a>〈/div>";

b2bStr[2]=”

left;width:

100%;overflow:

hidden;’〉

giftarget=_blank>〈br〉

gif>哈尔滨雪雕〈/a〉〈/div>”;

b2bStr[3]=”

left;width:

100%;overflow:

hidden;'>〈imgsrc=4.gifwidth=214pxheight=145pxborder=0〉〈/a>
〈atarget=_blanktitle=镜泊湖href=4。

gif〉镜泊湖〈/a〉

b2bStr[4]="〈divstyle='float:

left;width:

100%;overflow:

hidden;'>〈imgsrc=5.gifwidth=214pxheight=145pxborder=0>〈/a〉

gif>太阳岛公园瀑布〈/a>〈/div>”;

b2bStr[5]="〈divstyle=’float:

left;width:

100%;overflow:

hidden;’〉〈br〉〈atarget=_blanktitle=镜泊湖夜色href=6。

gif〉镜泊湖夜色〈/a〉〈/div〉";

varpage=0;

varspeed=3000;

functionshowPage(id){

page=id;

setTransition();

b2bContent.innerHTML=b2bStr[id];

b2bContent。

filters.revealTrans。

play();

}

functionturnPage(){

showPage(page);

theTimer=setTimeout("turnPage()",speed);

checkBt();

page++;

if(page>=6)page=0;

}

functioncheckBt(){

for(vari=0;i<6;i++){

btObj=eval('bt'+i);

if(page==i){btObj。

style.color='#FFFFFF’;btObj。

style.backgroundColor=’#FF781C';}

else{btObj.style。

color=’#000000’;btObj.style.backgroundColor='#F7F7F7’;}

}

}

functionsetTransition(){

b2bContent.filters。

revealTrans.Transition=Math.round(Math。

random()*23);

b2bContent。

filters.revealTrans.apply();

turnPage();

〈/script〉〈/TD>

〈hrcolor=”green"width=”540"〉

〈tablealign="center”〉

〈td>用户名:

〈/tr>

〈/tr>

〈tr〉

〈td〉

〈inputtype=”submit"value=”登录">  &nbsp; ;

〈inputtype="reset"value="取消”〉

〈/td>

〈/table>

〈/form〉

〈/body>

〈/html>

2。

java代码

(1)User.Java定义的属性和数据库中的字段相对应

packagecom。

softeem.dt;

publicclassUser{

privateintid;

privateStringusername;

privateStringpassword;

privateStringxh;

privateStringcollege;

publicintgetId(){

returnid;

publicvoidsetId(intid){

this.id=id;

}

publicStringgetUsername(){

returnusername;

}

publicvoidsetUsername(Stringusername){

this.username=username;

}

publicStringgetPassword(){

returnpassword;

}

publicvoidsetPassword(Stringpassword){

this.password=password;

publicStringgetXh(){

returnxh;

}

publicvoidsetXh(Stringxh){

this.xh=xh;

}

publicStringgetCollege(){

returncollege;

}

publicvoidsetCollege(Stringcollege){

this。

college=college;

(2)UserDAO。

java操作数据库tb_user,验证用户登录

packagecom。

softeem.dao;

importjava.sql。

Connection;

importjava。

sql。

PreparedStatement;

importjava。

sql。

ResultSet;

importjava.sql.SQLException;

importcom。

softeem.db.DBManager;

importcom。

softeem.dt.User;

publicclassUserDAO{

/**

*验证用户登录

*@return

*/

publicbooleancheckDenglu(Useruser){

booleanflag=false;

//获得数据库连接

Connectionconn=DBManager。

getConnection();

//用select*from查询数据库中的所有字段

Stringsql=”selectcount(*)fromtb_userwhereusername=?

andpassword=?

”;

try{

PreparedStatementpst=conn.prepareStatement(sql);

pst.setString(1,user。

getUsername());

pst。

setString(2,user.getPassword());

//执行查询语句,拿到结果集

ResultSetrs=pst.executeQuery();

while(rs.next()){

intcount=rs。

getInt

(1);

//用count和0比较,若大于0表示该用户存在,否则不存在

if(count〉0){

flag=true;

}

}catch(SQLExceptione){

e.printStackTrace();

}

returnflag;

}

3.LoginServlet,点击登录跳转到服务器端

packagecom.softeem.servlet;

importjava。

io。

IOException;

importjavax。

servlet.ServletException;

importjavax.servlet。

http.HttpServlet;

importjavax。

servlet.http.HttpServletRequest;

importjavax。

servlet。

http。

HttpServletResponse;

importcom.softeem.dao.UserDAO;

importcom.softeem.dto.User;

/**

*ServletimplementationclassLoginServlet

*/

publicclassLoginServletextendsHttpServlet{

privatestaticfinallongserialVersionUID=1L;

/**

*@seeHttpServlet#HttpServlet()

*/

publicLoginServlet(){

super();

}

/**

*@seeHttpServlet#doGet(HttpServletRequestrequest,HttpServletResponseresponse)

*/

protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{

super。

doGet(request,response);

/**

*@seeHttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse)

*/

protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{

//获取表单数据

//处理乱码

request.setCharacterEncoding(”utf—8”);

Stringusername=request.getParameter(”username”);

Stringpassword=request。

getParameter(”password");

//封装到user对象中

Useruser=newUser();

user.setUsername(username);

user。

setPassword(password);

//调用dao的checkLogin方法

UserDAOdao=newUserDAO();

booleanflag=dao。

checkLogin(user);

Stringmessage=null;

Stringpath=null;

if(flag){

message="登录成功";

path="success.jsp";

request。

getSession().setAttribute(”user”,user);

}else{

message="对不起密码错误,请重新输入!

";

path=”fail.jsp”;

//response返回message

response。

setCharacterEncoding(”utf-8");

response.getWriter().write(message);*/

//属于服务器跳转,浏览器地址栏没有发生改变request。

getRequestDispatcher(path).forward(request,response);

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2