jsp登录会话的简单实现
程序员文章站
2022-06-20 07:56:10
jsp登录会话的简单实现
<%@ page language="java" contenttype="text/html; charset=utf-8"...
jsp登录会话的简单实现
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>登录界面</title> </head> <body> <form action="test_session2.jsp" method="post"> <table width="300" height="300" border="0" align="center"> <tr height="80" align="center"> <td colspan="2"><font size="24">oo登录</font></td></tr> <tr height="30"> <td width="80" align="right">用户名:</td> <td><input type="text" name="name"></td></tr> <tr height="30"> <td width="80" align="right"> 密 码:</td> <td> <input type="password" name="password"></td></tr> <tr><td height="40" align="center" colspan="2"> <input type="submit" value="登录"></td></tr> </table> </body> </html>
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>登录成功</title> </head> <body> <% string name = new string( request.getparameter("name").getbytes("iso-8859-1"),"utf-8"); session.setattribute("name", name); out.println(name + "成功登陆"); %> <a href="test_session3.jsp"><br>跳转</a> </body> </html>
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>会话</title> </head> <body> <% string str = ""; object obj = session.getattribute("name"); if(obj != null){ str = obj.tostring(); out.println(str + "已经成功登陆"); }else{ out.println("会话超时,请重新登录。"); } %> </body> </html>
以上就是小编为大家带来的jsp登录会话的简单实现全部内容了,希望大家多多支持~
上一篇: “文青”是什么?为什么说魏晋时期的文青是文青中的战斗机?
下一篇: 女性在哺乳期可以喝红酒吗
推荐阅读
-
一个简单的短信验证码计时器实现教程
-
Android特别简单的banner实现自动轮播加底部小圆点
-
Spring整合Quartz实现一个简单的定时任务
-
一个简单的springmvc实现定时任务的例子
-
Cocos2d游戏开发学习记录——1.Surface、SurfaceView、SurfaceHolder实现简单的游戏demo
-
CSS3 实现的一个简单的"动态主菜单" 示例[转]_html/css_WEB-ITnose
-
PHP的时间戳与具体时间转化的简单实现,php具体时间转化
-
php简单定时执行任务的实现方法_php技巧
-
解析:通过php socket并借助telnet实现简单的聊天程序_php技巧
-
JSP网页实现拼音和汉字的上下对齐_html/css_WEB-ITnose