Session Object

 

HTTPÀÇ Æ¯Â¡Àº ¡°»óÅ°¡ ¾ø´Ù¡± ÀÔ´Ï´Ù. ±×·¯´Ï±î Web Server¿ÍÀÇ Åë½Å ÈÄ¿¡ connectionÀ» À¯Áö ÇÏÁö ¾Ê±â¿¡ ´Ù½Ã Åë½ÅÇÒ ¶§¿¡ ÀÌÀü¿¡ »óŸ¦ ¾Ë ¼ö ¾ø½À´Ï´Ù. ±×·¡¼­ ÄíÅ°¸¦ »ç¿ëÇÏ¿© »ç¿ëÀÚÀÇ Client¿¡ Á¤º¸¸¦ ÀúÀåÇÏ¿© ƯÁ¤ Á¤º¸¸¦ ÀúÀåÇÏ¿© ÀÌÀü Á¤º¸¸¦ º¸°üÇÑ´Ù.

 

±×·±µ¥ ¿ª½Ã ¹®Á¦´Â client¿¡¸¸ Á¤º¸¸¦ ÀúÀåÇÑ´Ù´Â °ÍÀÌ ¹®Á¦ÀÔ´Ï´Ù.  ServerÂÊ¿¡µµ ÇØ´ç Á¤º¸¸¦ ÀúÀåÇϸé Á» ´õ ¾ÈÀüÇÏ°Ô »ç¿ëÀÚÀÇ Á¤º¸¸¦ ´Ù·ê ¼ö ÀÖ°ÚÁö¿ä.  ÀÌ¿Í °°Àº ¿ªÇÒÀ» ÇÏ´Â °ÍÀÌ session À̶ó°í º»ÀÎÀº »ý°¢ÇÕ´Ï´Ù.

ÀϹÝÀûÀ¸·Î ¼îÇθô¿¡¼­ ¹°Ç° ±¸¸Å ÇÁ·Î¼¼½º¿¡ SessionÀ» ¸¹ÀÌ »ç¿ëÇÕ´Ï´Ù.

³Ê¹« ¸¹Àº seesionÀÇ »ç¿ëÀº server¿¡ ºÎÇϸ¦ ÁÙ ¼ö ÀÖ½À´Ï´Ù.

 

<html>

<body>

<font face=Arial>

<b><u>Implicit Object - Session</u></b><p>

<%

session.setMaxInactiveInterval(2*60);   // 2 min

%>

isNew() : <%= session.isNew() %><br>

getCreationTime : <%= session.getCreationTime() %><br>

getLastAccessedTime() : <%= session.getLastAccessedTime() %><br>

getId() : <%= session.getId() %><br>

getMaxInactiveInterval() : <%= session.getMaxInactiveInterval() %><p>

 

<%

             if(session.getAttribute("id") == null){

                           out.println("session setting<br>");

                           session.setAttribute("id","smson");

                           session.setAttribute("name","¼Õ»ó¸ð");

             }

              for (java.util.Enumeration e = session.getAttributeNames() ; e.hasMoreElements() ;) {

                            String name = e.nextElement().toString();

                            out.println(name + ":"+session.getAttribute(name)+"<br>");

              }

%>

</font></body></html>

 

óÀ½ session »ý¼º½Ã¿¡´Â isNewÀÇ °ªÀÌ true·Î ¼³Á¤µÇ°í ´Ù½Ã reload ½Ã¿¡´Â false°¡ ¼³Á¤ÀÌ µË´Ï´Ù.  ±×¸®°í 2ºÐ ÈÄ¿¡ reloadÇÏ¸é ´Ù½Ã true·Î ¼³Á¤ÇÏ°í ´Ù½Ã±Ý sessionÀ» ¼³Á¤ÇÏ´Â °ÍÀ» º¼ ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.

 

Application Object

 

Á¦°¡ óÀ½ ASP¸¦ °øºÎÇÒ ¶§ IIS¿¡¼­ÀÇ global.asa¸¦ º¸°í ¿ª½Ã MS¶ó°í »ý°¢ÇßÁö¿ä. ÀÌÀ¯´Â Web ApplicationÀÇ °³³ä ¶§¹®À̾ú½À´Ï´Ù.

Web ApplicationÀº URL °¢°¢¿¡ µû¶ó ScriptµéÀÌ ¹­ÀÎ ´ÜÀ§ÀÌ°í ´ëºÎºÐÀÇ ServerµéÀº URLÀÇ µð·ºÅ丮º°·Î ApplicationÀ» ¹­À» ¼ö ÀÖ½À´Ï´Ù.  ±×¸®°í ÀÌ¿Í °°ÀÌ ¹­ÀÎ Application º°·Î ¼³Á¤°ªÀ» °øÀ¯ÇÑ´Ù´Â °ÍÀÔ´Ï´Ù.

 

http://www.ihelpers.co.kr/programming/index.jsp

http://www.ihelpers.co.kr/programming/right1.jsp

http://www.ihelpers.co.kr/programming/work/index.jsp

 

À§¿¡¼­´Â programmingÀ¸·Î ApplicationÀ» ¹­À» ¼ö ÀÖ°Ú±º¿ä. JSP¿¡¼­´Â Web Application Descriptor ÆÄÀÏÀ» »ç¿ëÇÏ¿© Application ±×·ìÈ­¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù°í Çϴ±º¿ä. ( ¾ÆÁ÷Àº º»Àεµ Àß ¸ð¸§ )

 

<%@ page contentType="text/html;charset=euc-kr" %>

<html>

<body>

<font face=Arial>

<b><u>Implicit Object - Application</u></b><p>

 

Servlet API Version :

<%= application.getMajorVersion()%>.<%= application.getMinorVersion()%><br>

Container Version : <%= application.getServerInfo() %><br>

Context Root Directory : <%= application.getRealPath("/") %><br>

</font>

</body>

</html>

 

 

Reference Site

- http://www.jspschool.com

 

Reference Book

- Web Development with Java Server Pages. by Duane K. Fields & Mark A. Kolb ,°û¿ëÀçÆí¿ª ; InfoBook, Manning

- ÆÛÆåÆ® JSP; ¾ÓÈñ¼®,Ç¥¼±¿µ Àú; ÇѺû¹Ìµð¾î