首页 > 代码库 > session应用:
session应用:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" session="true"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>登录</title> </head> <body> sessionID<%=session.getId() %> <% Object username=session.getAttribute("username"); if(username==null){ username=""; } %> <form action="hello.jsp" method="post"> username:<input type="text" name="username" value="<%= username %>"/> <input type="submit" value="http://www.mamicode.com/Submit"/> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" session="true"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>HELLO SESSION</title> </head> <body> sessionID<%=session.getId() %> <%=request.getParameter("username") %> <% session.setAttribute("username", request.getParameter("username")); %> <a href="http://www.mamicode.com/<%= response.encodeURL("login.jsp") %>">重新登录</a> <a href="http://www.mamicode.com/<%= response.encodeURL("zhuxiao.jsp") %>">注销</a> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" session="true"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>注销</title> </head> <body> sessionId:<%=session.getId() %> <h3>Session</h3> Bye: <%= session.getAttribute("username") %> <% session.invalidate(); %> </body> </html>
session应用:
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。