<%@ 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>Insert title here</title> </head> <body> <% //out.write(session.toString()+" "+session.isNew()); if(session==null){ out.write("session not creat"); } else if(session.getAttribute("name")==null||session.getAttribute("name").equals("")){ out.write("<a href='login.jsp'>登录</a>"); } else{ out.write(session.getAttribute("name")+"你好"); } %> / <a href="index.jsp" onclick="logout()">注销</a> <script type="text/javascript"> function logout(){ <% session.invalidate(); %> } </script> </body> </html>
相关文章: