jsp登录会话

发布时间:2017-09-07 13:50:01
jsp登录会话



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>
</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"> 密&nbsp;&nbsp;码:</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" "">
<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" "">
<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>

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:天门SEO http://tianmen.4567w.com


友情链接

独家出品

新闻由机器选取每5分钟自动更新

新闻搜索源于互联网新闻网站和频道,系自动分类排列,本站不刊登或转载任何完整的新闻内容