´ÙÀ½ ÀÌÀü Â÷·Ê

7. Web Application,war,web.xml

ÀÌ ºÎºÐÀº Java Servlet Specification Version 2.2 ¸¦ ÂüÁ¶ÇÏ¿´´Ù. ÀÌ Àå¿¡ ¼Ò°³µÈ ³»¿ë¿Ü´Â ÀÌ ¹®¼­¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.

Web Application À̶õ Servlet,JSP,HTML¹®¼­,±âŸ À̹ÌÁö³ª ¾ÐÃàµÈ ÀÚ·á ¹× ´Ù¸¥ µ¥ÀÌŸ¸¦ Æ÷ÇÔÇÏ´Â Web °ü·Ã ¸®¼Ò½ºÀÌ´Ù.

ÀÌ·¯ÇÑ Web Application À» ¾ÐÃàÇÏ¿© ¹èÆ÷Çϱâ À§ÇÑ ÆÄÀÏÀÌ WAR ÆÄÀÏÀÌ´Ù. WAR ÆÄÀÏÀº Web Application ArchiveÀÌ¸ç µð·ºÅ丮¸¦ Æ÷ÇÔÇÏ¿© ¾ÐÃà ȤÀº ÆÐÅ°ÁöµÈ ÇϳªÀÇ ÆÄÀÏÀÌ´Ù.

web.xmlÀº Deployment Descriptor À̸ç XML À» ¾Ë°í ÀÖ´Â ºÐÀº $TOMCAT_HOME/conf/web.dtd¸¦ º¸±â ¹Ù¶õ´Ù. web.xmlÀÇ ¿ä¼Ò´Â deployment Á¤º¸ ¹× ȯ°æ ¼³Á¤ µîÀÌ¸ç ´ÙÀ½°ú °°´Ù.

web.xml ÆÄÀÏÀº $TOMCAT_HOME/webapps/user_app/WEB-INF µð·ºÅ丮¿¡ À§Ä¡Çϸç user_app µð·ºÅ丮 ÀÌÇÏ¿¡ ÀÖ´Â Web Application ÀÇ È¯°æ ¼³Á¤ ºÎºÐÀ» ´ã´ãÇÑ´Ù°í º¸¸é µÈ´Ù. Áï, ¸ðµç Web Application ÀÌ ¾Æ´Ñ ƯÁ¤ Web Application ¸¸ÀÇ È¯°æ ¼³Á¤¸¸À» Çϸç, WAR ÆÄÀÏ·Î ÆÐÅ°Áö µÉ ¶§ °°ÀÌ Æ÷ÇԵȴÙ.

WEB-INF µð·ºÅ丮¿¡´Â web.xml ÆÄÀÏ°ú classes µð·ºÅ丮 ±âŸ lib µð·ºÅ丮°¡ À§Ä¡ÇÑ´Ù. Âü°í·Î classes µð·ºÅ丮¿¡ servlet °ú utility class µîÀÌ À§Ä¡ ÇÒ ¼ö ÀÖ´Ù.

Âü°í·Î web.xmlÀº °¢°¢ÀÇ »ç¿ëÀÚ µð·ºÅ丮¸¦ ¸¸µç ÈÄ ÇØ´ç µð·ºÅ丮¿¡ ´ëÇÑ ÀûÀýÇÑ ¼³Á¤ ÈÄ $TOMCAT_HOME/conf/web.xml À» $TOMCAT_HOME/webapps/ÇØ´ç_µð·ºÅ丮/WEB-INF/¿¡ º¹»çÇÏ¿© »ç¿ëÇÑ´Ù. web.xml¼³Á¤Àº °¢ÀÚÀÇ web application ¿¡ ¸Â°Ô ¼³Á¤ÇÑ´Ù.

´ÙÀ½Àº web.dtd ¹× web.xmlÀÇ °£´ÜÇÑ ¼³¸í°ú ¿¹¸¦ º¸ÀÌ°Ú´Ù. ¶ÇÇÑ web.dtd ¹× web.xmlÀÇ ÀÌÇظ¦ µ½±â À§ÇØ xml ¿¡ ´ëÇÑ °£´ÜÇÑ ¼³¸íÀ» Çϵµ·Ï ÇÏ°Ú´Ù.

´ÙÀ½Àº $TOMCAT_HOME/conf/web.dtd ÀÇ ÀϺκÐÀÌ´Ù.

<!--(ÁÖ¼®) The session-timeout element defines the default session 
timeout interval for all sessions created in this web application. 
The specified timeout must be expressed in a whole number of minutes.-->
<!ELEMENT session-timeout (#PCDATA)>
<!ATTLIST session-timeout id ID #IMPLIED>
...........
...........
<!--(ÁÖ¼®) The welcome-file-list contains an ordered list of 
welcome files elements. -->
<!ELEMENT welcome-file-list (welcome-file+)>
<!ATTLIST welcome-file-list id ID #IMPLIED>
<!--(ÁÖ¼®) The welcome-file element contains file name to use 
as a default welcome file, such as index.html-->
<!ELEMENT welcome-file (#PCDATA)>
<!ATTLIST welcome-file id ID #IMPLIED>

À§ÀÇ <!ELEMENT session-timeout (#PCDATA)> session ÀÇ µðÆúÆ® Time-Out ½Ã°£À» ¼³Á¤Çϵµ·Ï ÇÏ´Â ¿ä¼Ò·Î¼­ ¿ä¼Ò Á¤ÀÇ ºÎºÐÀÌ´Ù. (#PCDATA)´Â ´Ü¸» ³ëµå¸¦ ÀǹÌÇÏ¸ç ½ºÆ®¸µÀÌ ¿À¸é µÈ´Ù. (Âü°í·Î xml Àº Æ®¸® ±¸Á¶ÀÌ´Ù.)

<!ATTLIST session-timeout id ID #IMPLIED> Àº session-timeout ¿ä¼Ò¿¡ ´ëÇÑ ¼Ó¼ºÀÇ Á¤ÀÇ ºÎºÐÀÌ´Ù. #IMPLIED´Â session-timeout ¿ä¼ÒÀÇ id °¡ »ý·«°¡´ÉÇÔÀ» ÀǹÌÇÑ´Ù. Áï, <session-timeout id="123dc56"> ó·³ µÇ¾î¾ß Çϳª #IMPLIED ·Î ÀÎÇØ <session-timeout> °¡ µÇ¾îµµ µÈ´Ù.

welcome-file Àº web-application ÀÇ welcome-fileÀ» Á¤ÀÇÇÏ¸ç ¾ÆÆÄÄ¡ÀÇ DocumentRootÀÇ index.html °ú °°´Ù°í º¸¸é µÈ´Ù. (welcome-file+) Àº welcome-file-list ¿ä¼ÒÀÇ Àڽijëµå¸¦ Á¤ÀÇ Çϸç "+" welcome-file ¿ä¼Ò°¡ Çϳª ÀÌ»ó À־ µÈ´Ù´Â ÀǹÌÀÌ´Ù. ¾Æ·¡ÀÇ web.xml ÀÇ ¿¹ÀÇ welcome-file-list ¿ä¼Ò³»ÀÇ welcome-file¿ä¼Òµéó·³ ´Ù¼ö°¡ ¿Ã ¼ö ÀÖ´Ù´Â ÀǹÌÀÌ´Ù.

´ÙÀ½Àº $TOMCAT_HOME/conf/web.xmlÀÇ ÀϺκÐÀÌ´Ù.

<session-timeout>
  30
</session-timeout>
..........
..........
<welcome-file-list>
<welcome-file>
   index.jsp
</welcome-file>
<welcome-file>
   index.html
</welcome-file>
<welcome-file>
   index.htm 
</welcome-file>
</welcome-file-list>


´ÙÀ½ ÀÌÀü Â÷·Ê