05.JSP2008. 11. 13. 15:29
반응형

<%-- requestSession.jsp --%>
%@page import="java.util.*" contentType="text/html;charset=euc-kr"%

<HTML><HEAD><TITLE>세션과 쿠키정보</TITLE></HEAD>

<BODY style="font-size:9pt">
<H3> 세션 정보출력</H3>
<%
         HttpSession sess = request.getSession(true);
         out.print("<b>[Requested Session유효여부]:</b>" +  request.isRequestedSessionIdValid() + "<BR>");
         out.print("<b>[Session 쿠키사용여부]:</b>" + request.isRequestedSessionIdFromCookie() + "<BR>");
         out.print("<b>[Session URL사용여부]:</b>" + request.isRequestedSessionIdFromURL() + "<BR>");
         out.print("<b>[Requested Session Id]:</b>" + request.getRequestedSessionId() + "<BR>");
         out.print("<b>[Session ID]:</b>" + sess.getId());
%>

<H3>쿠키정보출력</H3>
<%

         Cookie [] cookies = request.getCookies();
         for(int i = 0; i < cookies.length; i++) {
                  out.print("<b>" + cookies[i].getName() + "</b>: " + cookies[i].getValue());
         }
%>
</FONT></BODY></HTML>

Posted by 1010