Site Search :
Standard Enterprise XML Methodology Pattern Setting Tunning Other
Article Contributors
GuestBook
Javapattern Maven
XSourceGen Dev
JetSpeed Test
JLook Image
jLook Family Site


URL RewritingÀ» ÀÌ¿ëÇÑ session tracking
 
cookie³ª session ÀÌ Áö¿øµÇÁö¾ÊÀ» °æ¿ì server¿Í client»çÀÌ¿¡¼­ ÀÏÁ¤ÇÑ session À» À¯ÁöÇϱâ À§ÇÑ URL Rewriting¹æ¹ý ( 2003/03/31 ) 614
Written by ienvyou - ÃÖÁö¿õ
2 of 2
 

3. URL Rewriting ½Ã »ç¿ëµÇ´Â Method.

HttpServletResponse Interface ÀÇ

String encodeURL(java.lang.String url)

ÀÌ methodÀÇ ¿ªÇÒÀº »ç¿ëÀÚ¿¡°Ô Àü´Þ µÇ¾î Áö´Â URLÁ¤º¸¿¡ Ãʱ⿡ Á¢¼ÓÇßÀ»¶§ÀÇ ¸¸µé¾îÁø session id¸¦ URLÁ¤º¸¿¡ Æ÷ÇÔ½ÃÄÑ client Browser·Î º¸³»°Ô µË´Ï´Ù.

±×·¸°Ô ÇÔÀ¸·Î¼­ ¸Å Á¢¼Ó½Ã »õ·Î¿î session id°¡ ¸¸µé¾î Á®µµ Ãʱâ login½Ã¿¡ ¸¸µé¾îÁö´Â session id¸¦ ±×´ë·Î logout½Ã°¡Áö »ç¿ëÇÏ°Ô µË´Ï´Ù.

4. URL Rewriting ¸¦ ÀÌ¿ëÇÑ ¿¹Á¦.

source: booklist2.jsp

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>Book List </p>
<table border="1" width="183">
<tr>
<td height="50" width="48"><img src="book1.jpg" width="45" height="60"></td>
<td height="50" width="119"><a href=<%=response.encodeURL("Cart.jsp?content=book1")%>>±¸¸Å</a></td>
</tr>
<tr>
<td height="48" width="48"><img src="book2.jpg" width="48" height="60"></td>
<td height="48" width="119"><a href=<%=response.encodeURL("Cart.jsp?content=book2")%>>±¸¸Å</a></td>
</tr>
</table>
<p>&nbsp; </p>
</body>
</html>


À§ÀÇ sourceó·³ Cart.jsp¿¡´Â ¾Æ¹« º¯È­°¡ ¾ø°í óÀ½ »ç¿ëÀÚ¿¡°Ô º¸¿©Áö´Â ºÎºÐ¿¡¼­ ¸µÅ© µÇ¾îÁö´Â ºÎºÐ¿¡ reponse.encodeURL("URL")Á¤º¸¸¦ »ç¿ëÇÏ°Ô µË´Ï´Ù.

±¸¸Å ¶ó´Â ¸µÅ© ´Ü¾î¿¡´Â ´ÙÀ½°ú °°Àº URLÁ¤º¸°¡ ³ªÅ¸³ª°ÔµË´Ï´Ù.

http://localhsot/Cart.jsp;sessionid=XXXXXXXX?content=book1

 

5. Form À» ÀÌ¿ëÇÑ °æ¿ì

source:booklistform.jsp

<html>
<head>
<title>Untitled Document</title>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>Book List </p>
<form name="form" method="post" action="<%=response.encodeURL("Cart.jsp")%>">
<table border="1" width="183">
<tr>
<td height="50" width="48"><img src="book1.jpg" width="45" height="60"></td>
<td height="50" width="119">
<input type="submit" name="content" value="book1" >
</td>
</tr>
<tr>
<td height="48" width="48"><img src="book2.jpg" width="48" height="60"></td>
<td height="48" width="119">
<input type="submit" name="content" value="book2">
</td>
</tr>
</table>
</form>
<p>&nbsp; </p>
</body>
</html>

ÀÌ·¸°Ô formÀ» ÀÌ¿ëÇÒ °æ¿ì ´Â actionºÎºÐ¿¡ response.encodeURL("Cart.jsp")À» ÀÌ¿ëÇϸé À̺¥Æ® ¹ß»ý½Ã ÇØ´ç session id¸¦ ÀÌ¿ëÇÏ¿© ó¸®ÇÏ°Ô µË´Ï´Ù.

Àüü source: url.zip

ÃÖ±Ù ¸¸µé¾îÁö´Â ¸¹Àº ÀüÀÚ »ó°Å·¡ ½ÎÀÌÆ®¸¦ À¯½ÉÈ÷ º¸½Ã¸é ÀÌ·¸°Ô URL RewritingÀ» ÀÌ¿ëÇÑ ½ÎÀÌÆ®µéÀÌ ¸¹¾Æ Áö°í ÀÖ½À´Ï´Ù. ±âº»ÀûÀ¸·Î »ç¿ëÀÚ´Â ¾î¶² »óȲ¿¡¼­µµ ÀüÀÚ »ó°Å·¡°¡ ÀÌ·ç¾î Á®¾ß ÇÑ´Ù´Â °³³äÀÌÁÒ Áï PC»Ó¸¸ÀÌ ¾Æ´Ï¶ó ¾ÕÀ¸·Î mobileÀ̳ª ¿©·¯ platformÀ» ÀÌ¿ëÇÏ°Ô µÈ´Ù¸é Ç×»ó »ç¿ëÀÚ´Â ÀüÀÚ »ó°Å·¡¸¦ À§ÇÑ ¸ðµç Áغñ°¡ µÇ¾î ÀÖ´Â °ÍÀº ¾Æ´Õ´Ï´Ù.

´Ü ÀÌ°æ¿ì browser»ó¿¡ »ç¿ëÀÚ session id °¡ ³ëÃ⠵DZ⠶§¹®¿¡ »ç¿ëÀÚ°¡ loginÇÒ¶§ÀÇ ½Ã°£À» ÃÊ´ÜÀ§±îÁö Àӽ÷ΠÀúÀåÇØ ³õ°í ´Ù¸¥ »ç¿ëÀÚ°¡ Á¢±Ù ÇÏ´Â °ÍÀ» ¸·´Â ¹æ¹ýÀ» äÅÃÇÑ´ÙµçÁö ¿©·¯ ºÎ°¡ÀûÀÎ ¹æ¹ý¶ÇÇÑ Ãß°¡ ½ÃÄÑ¾ß ÇÕ´Ï´Ù.

 
1 2
References
 
Copyright ¨Ï 2003 www.javapattern.info & www.jlook.com, an jLOOK co.,LTD