선택장애

JSP - Sesstion(alert) 본문

JSP

JSP - Sesstion(alert)

yes or yes 2017. 8. 14. 14:52
반응형

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<center>
<H1>SESSION 예제</H1>
<hr>
<%
 // is New() 메서드를 이용해 최초 세션 설정을 확인하고 있다.
 
 if(session.isNew())
 {
  out.println("<script> alert('세션이 헤재되어 다시 설정합니다.') </script>");
  session.setAttribute("login", "홍길동"); 
 }
 //session이 살아 있기 때문에 새로고침해도 알림창이 안 뜬다. 완전히 껏다켜야한다.
%>
# <%= session.getAttribute("login") %> 님 환영합니다.!!! <br>
1. 세션 ID : <%= session.getId() %><br>
2. 세션 유지시간 : <%= session.getMaxInactiveInterval() 
%><Br>
</center>
</body>
</html>

반응형