You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by as...@apache.org on 2007/09/08 22:17:47 UTC
svn commit: r573901 [41/44] - in /cocoon/site: site/ site/2.0/
site/2.0/developing/ site/2.0/faq/ site/2.0/howto/chaperon/
site/2.0/installing/ site/2.0/plan/ site/2.0/snippet/ site/2.0/tutorial/
site/2.0/userdocs/ site/2.0/userdocs/actions/ site/2.0/u...
Modified: cocoon/site/site/2.0/userdocs/xsp/sessions.html
URL: http://svn.apache.org/viewvc/cocoon/site/site/2.0/userdocs/xsp/sessions.html?rev=573901&r1=573900&r2=573901&view=diff
==============================================================================
--- cocoon/site/site/2.0/userdocs/xsp/sessions.html (original)
+++ cocoon/site/site/2.0/userdocs/xsp/sessions.html Sat Sep 8 13:17:41 2007
@@ -1,478 +1,478 @@
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Session tracking with Cocoon</title>
-<STYLE type="text/css">
-a.menu {
- color: #FFFFFF;
- text-align:left;
- font-size:12px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight:plain;
- text-decoration:none;
- padding-left: 14px
-}
-
-A.menu:hover {
- color: #FFCC00
-}
-
-
-.menutitle {
- color: #000000;
- text-align:left;
- font-size:10px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight:bold;
- padding-left: 8px
-}
-.menuselected {
- color: #FFCC00;
- text-align:left;
- font-size:12px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-weight:bold;
- padding-left: 14px
-}
-</STYLE>
-</head>
-<body bgcolor="#ffffff" marginheight="4" marginwidth="4" leftmargin="4" topmargin="4" alink="#cc0000" vlink="#0086b2" link="#039acc" text="#000000">
-<table border="0" cellpadding="0" cellspacing="0" width="100%">
-<tr>
-<td align="left" valign="top" rowspan="3" height="60" width="135"><img border="0" vspace="0" hspace="0" src="images/logo.gif" height="60" width="135"></td><td background="images/line.gif" rowspan="1" colSpan="2" align="left" valign="top" height="0" width="100%"></td><td align="left" valign="top" rowspan="3" height="60" width="29"><img border="0" vspace="0" hspace="0" src="images/right.gif" height="60" width="29"></td>
-</tr>
-<tr>
-<td bgcolor="#0086b2" colspan="2" align="right" valign="top" height="35" width="100%"><font color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif" size="5">Session tracking with Cocoon</font></td>
-</tr>
-<tr>
-<td background="images/bottom.gif" colspan="2" width="100%" valign="top" height="20" bgcolor="#0086b2" align="right">
-<table width="288" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td align="left" valign="top" height="20" width="96"><a target="new" href="http://xml.apache.org/"><img border="0" vspace="0" hspace="0" name="xml" src="images/button-xml-lo.gif" height="20" width="96" alt="http://xml.apache.org/"></a></td><td align="left" valign="top" height="20" width="96"><a target="new" href="http://www.apache.org/"><img border="0" vspace="0" hspace="0" name="asf" src="images/button-asf-lo.gif" height="20" width="96" alt="http://www.apache.org/"></a></td><td align="left" valign="top" height="20" width="96"><a target="new" href="http://www.w3.org/"><img border="0" vspace="0" hspace="0" name="w3c" src="images/button-w3c-lo.gif" height="20" width="96" alt="http://www.w3.org/"></a></td>
-</tr>
-</table>
-</td>
-</tr>
-</table>
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr width="100%">
-<td align="left" valign="top" width="120">
-<table width="120" cellspacing="0" cellpadding="0" border="0" bgcolor="#a0a0a0">
-<tr>
-<td valign="top" align="left"><img width="120" vspace="0" src="images/join.gif" hspace="0" height="14" border="0"><br>
-</td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="../../index.html">Main</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="../index.html">User Documentation</a></td>
-</tr>
-<tr>
-<td background="images/label-background_b.gif" bgcolor="#959595" valign="top"><img width="120" height="6" src="images/separator.gif"><br>
-<span class="menutitle">XSP</span></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="index.html">Overview</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet.html">XSP Guide</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="xsp-internals.html">XSP Internals</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet-concepts.html">XSP Logicsheets</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><span class="menuselected">Sessions</span></td>
-</tr>
-<tr>
-<td background="images/label-background_b.gif" bgcolor="#959595" valign="top"><img width="120" height="6" src="images/separator.gif"><br>
-<span class="menutitle">Logicsheets</span></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="request.html">Request</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="session.html">Session</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="esql.html">ESQL</a></td>
-</tr>
-<tr>
-<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet-forms.html">Forms</a></td>
-</tr>
-<tr>
-<td align="left" valign="top"><img width="120" vspace="0" src="images/close.gif" hspace="0" height="14" border="0"><br>
-</td>
-</tr>
-</table>
-</td><td>
-<table cellspacing="15" cellpadding="0" border="0">
-<tr>
-<td>
-
-
-
-
- <font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Introduction</font>
-<hr style="color: #0086b2" size="1">
-
-<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>Goal</b></font>
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- Maintaining state is a common problem for web server frameworks
- because HTTP is a stateless protocol. There are many solutions known
- to obtain stateful information. Client-side storage of state information
- like the usage of cookies will not be discussed here, since this depends
- heavily on the client's browser. Since Cocoon is a server-side framework,
- storing visitor information at the server side will give full access
- to the list of all visitors, to what they have done, and what they are
- doing.
- </font>
-</p>
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">Please always think a little while if you really want to set up
- session management. Less scalability and performance is the dark
- side of keeping user sessions at the server-side. Each user session consumes
- memory, disk, and CPU, and it is always recommended that you be careful to
- system resources before wasting it.
- </font>
-</p>
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- If you decided to set up session tracking, Cocoon offers you:
- </font>
-</p>
-
-<blockquote>
-<ul>
-
-<li>
-<font face="verdana, helvetica, sans serif">creation of new session IDs</font>
-</li>
-
-<li>
-<font face="verdana, helvetica, sans serif">full session control by the underlying Servlet API 2.2 servlet engine</font>
-</li>
-
-<li>
-<font face="verdana, helvetica, sans serif">cookie- and URI-based session management</font>
-</li>
-
-<li>
-<font face="verdana, helvetica, sans serif">automatic link rewrite if you like your XSP pages to be URI-session-aware</font>
-</li>
-
-</ul>
-</blockquote>
-
-
-
-
-<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>The xsp-session:encode-url template</b></font>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- To enable Cocoon for URI-based session IDs, an XSP template with the name
- <code><font face="courier, monospaced">xsp-session:encode-url</font></code> will do this for you. It uses the
- <code><font face="courier, monospaced">encodeURL</font></code> method from the Servlet API which encodes
- an URL in a way that a session ID is being attached. Consult your
- servlet engine documentation for information about what the <code><font face="courier, monospaced">encodeURL</font></code>
- method returns. For example, the Tomcat
- engine adds a string <code><font face="courier, monospaced">;jsession=</font></code> followed by an MD5 hash
- to the URL, but only if the client's browser does not accept cookies.
- </font>
-</p>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">Here is the fragment for the <code><font face="courier, monospaced">xsp-session:encode-url</font></code> from session.xsl:</font>
-</p>
-
-
-<div align="center">
-<table border="0" cellpadding="0" cellspacing="4">
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
-<pre>
-<!-- encode an URL with the session ID -->
-<xsl:template match="xsp-session:encode-url">
- <xsl:variable name="href">
- "<xsl:value-of select="@href"/>"
- </xsl:variable>
-
- <xsp:element name="a">
- <xsp:attribute name="href">
- <xsp:expr>
- response.encodeURL(String.valueOf(<xsl:copy-of select="$href"/>))
- </xsp:expr>
- </xsp:attribute>
- <xsl:value-of select="."/>
- </xsp:element>
-
-</xsl:template>
-</pre>
-</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-</table>
-</div>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- As you might wonder, the XSP template constructs a HTML tag <code><font face="courier, monospaced"><a></font></code> with an
- attribute <code><font face="courier, monospaced">href</font></code> which is enough for most of the cases.
- Other methods, like XLink, are planned to be supported at a later time when
- final W3C recommendations are out.
- </font>
-</p>
-
-
-
-
-<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>Creating new sessions</b></font>
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- The best place of a web site where new sessions should be created is the entry point
- where all or most of the visitors step in. After creating the session, or
- retrieving an old session, the visitor is redirected to a start page.
- In Cocoon, you must edit your sitemap in order to
- specify this interesting point of session creation.
- The <code><font face="courier, monospaced">map-redirect-to</font></code>
- has an extra attribute <code><font face="courier, monospaced">session</font></code>, which can be set to <code><font face="courier, monospaced">true</font></code>
- or <code><font face="courier, monospaced">false</font></code>. The former will generate a new session ID if needed
- by invoking the Servlet API method <code><font face="courier, monospaced">session = request.getSession(true)</font></code>,
- while the latter ignores session ID handling.
- </font>
-</p>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- How can Cocoon recognize URIs with appended session IDs? The answer is:
- Cocoon can match a wildcard against your sessionized pages and keeps happy.
- So please do not forget to append an asterisk '*' to your patterns in the pipelines.
- </font>
-</p>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- This fragment from <code><font face="courier, monospaced">sitemap.xsl</font></code> shows how you can add a
- <code><font face="courier, monospaced">map:redirect-to</font></code> to
- your Cocoon framework with session handling at the root URL for your
- web application:
- </font>
-</p>
-
-
-<div align="center">
-<table border="0" cellpadding="0" cellspacing="4">
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
-<pre>
-
- <map:pipelines>
- <map:pipeline>
-
- <map:match pattern="">
- <map:redirect-to session="true" uri="welcome"/>
- </map:match>
-
- <map:match pattern="welcome*">
- <map:generate type="file" src="site/welcome.xml"/>
- <map:transform src="stylesheets/welcome.xsl"/>
- <map:serialize/>
- </map:match>
-
- <map:match pattern="**.xsp*">
- <map:generate type="serverpages" src="site/{1}.xsp"/>
- <map:transform src="stylesheets/dynamic-page2html.xsl"/>
- <map:serialize/>
- </map:match>
-</pre>
-</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-</table>
-</div>
-
-
-
-
-<font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Example</font>
-<hr style="color: #0086b2" size="1">
-
-<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>A simple XSP page with session ID</b></font>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- Here you can see the source of an XSP example of how the
- session feature can be used.
- The example is located in a file named <code><font face="courier, monospaced">sessionpage.xsp</font></code>
- and it displays the received session ID together with a rewritten
- link to the page itself. Depending on your browser settings,
- you will see nothing (because your browser prefers crunching cookies)
- or a session ID is encoded into the URL. After clicking on the
- link named "Follow me!", the session ID is taken into the URL, and
- the session tracking is established.
- </font>
-</p>
-
-
-<div align="center">
-<table border="0" cellpadding="0" cellspacing="4">
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
-<pre>
-<?xml version="1.0" encoding="iso-8859-1"?>
-
-<xsp:page
- language="java"
- xmlns:xsp="http://apache.org/xsp"
- xmlns:xsp-session="http://apache.org/xsp/session/2.0"
- xmlns:xsp-request="http://apache.org/xsp/request/2.0"
->
-
-<!-- a simple session page by J&ouml;rg Prante <joerg@7val.com> -->
-
-<page>
- <title>A Simple URI-based Session Example</title>
- <content>
- <para> <xsp-request:get-uri as="xml"/> </para>
- <para> Session ID = <xsp-session:get-id as="xml"/> </para>
- <para>
- Encode URL Test =
- <xsp-session:encode-url href="sessionpage.xsp">Follow me!</xsp-session:encode-url>
- </para>
- </content>
-</page>
-
-</xsp:page>
-</pre>
-</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-</table>
-</div>
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- If you have been successful with installing the session feature and
- the example file, the following HTML output will be generated by
- Cocoon from the above <code><font face="courier, monospaced">sessionpage.xsp</font></code> example, which shows
- how the rewritten link looks like. Please don't ask
- why the session ID in the generated link is different from yours.
- </font>
-</p>
-
-
-<div align="center">
-<table border="0" cellpadding="0" cellspacing="4">
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
-<pre>
-<!DOCTYPE HTML PUBLIC
- "-//W3C//DTD HTML 4.0//EN"
- "http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd">
-<html><head><title>
- A Simple URI Session Example
- </title></head>
- <body vlink="blue" link="blue" alink="red" bgcolor="white">
-
- <h2 style="color: navy; text-align: center">
- A Simple URI Session Example
- </h2>
-
- <content>
-
- <p align="left"><i>
- <b xmlns:xsp-response="http://apache.org/xsp/response/2.0"
- xmlns:xsp-request="http://apache.org/xsp/request/2.0">
- sessionpage.xsp</b>
- </i></p>
-
- <p align="left"><i>
- Session ID =
- <xsp-session:id>F3E9575442D1899760A0B231D0042281</xsp-session:id>
- </i></p>
-
- <p align="left"><i>
- Encode URL Test =
- <a href="sessionpage.xsp;jsessionid=F3E9575442D1899760A0B231D0042281">
- Follow me!</a>
- </i></p>
- </content>
-
-</body></html>
-</pre>
-</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-<tr>
-<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
-</tr>
-</table>
-</div>
-
-
-
-
-
-<font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Log analysis of sessions</font>
-<hr style="color: #0086b2" size="1">
-
-
-<p>
-<font color="black" face="verdana,helvetica,sanserif">
- To be done.
- </font>
-</p>
-
-
-
-
-
-</td>
-</tr>
-</table>
-</td>
-</tr>
-</table>
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td bgcolor="#0086b2"><img width="1" src="images/dot.gif" height="1"></td>
-</tr>
-<tr>
-<td align="center"><font size="-1" face="arial,helvetica,sanserif" color="#0086b2"><i>Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.</i></font></td>
-</tr>
-</table>
-</body>
-</html>
+<html>
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Session tracking with Cocoon</title>
+<STYLE type="text/css">
+a.menu {
+ color: #FFFFFF;
+ text-align:left;
+ font-size:12px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight:plain;
+ text-decoration:none;
+ padding-left: 14px
+}
+
+A.menu:hover {
+ color: #FFCC00
+}
+
+
+.menutitle {
+ color: #000000;
+ text-align:left;
+ font-size:10px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight:bold;
+ padding-left: 8px
+}
+.menuselected {
+ color: #FFCC00;
+ text-align:left;
+ font-size:12px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight:bold;
+ padding-left: 14px
+}
+</STYLE>
+</head>
+<body bgcolor="#ffffff" marginheight="4" marginwidth="4" leftmargin="4" topmargin="4" alink="#cc0000" vlink="#0086b2" link="#039acc" text="#000000">
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tr>
+<td align="left" valign="top" rowspan="3" height="60" width="135"><img border="0" vspace="0" hspace="0" src="images/logo.gif" height="60" width="135"></td><td background="images/line.gif" rowspan="1" colSpan="2" align="left" valign="top" height="0" width="100%"></td><td align="left" valign="top" rowspan="3" height="60" width="29"><img border="0" vspace="0" hspace="0" src="images/right.gif" height="60" width="29"></td>
+</tr>
+<tr>
+<td bgcolor="#0086b2" colspan="2" align="right" valign="top" height="35" width="100%"><font color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif" size="5">Session tracking with Cocoon</font></td>
+</tr>
+<tr>
+<td background="images/bottom.gif" colspan="2" width="100%" valign="top" height="20" bgcolor="#0086b2" align="right">
+<table width="288" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td align="left" valign="top" height="20" width="96"><a target="new" href="http://xml.apache.org/"><img border="0" vspace="0" hspace="0" name="xml" src="images/button-xml-lo.gif" height="20" width="96" alt="http://xml.apache.org/"></a></td><td align="left" valign="top" height="20" width="96"><a target="new" href="http://www.apache.org/"><img border="0" vspace="0" hspace="0" name="asf" src="images/button-asf-lo.gif" height="20" width="96" alt="http://www.apache.org/"></a></td><td align="left" valign="top" height="20" width="96"><a target="new" href="http://www.w3.org/"><img border="0" vspace="0" hspace="0" name="w3c" src="images/button-w3c-lo.gif" height="20" width="96" alt="http://www.w3.org/"></a></td>
+</tr>
+</table>
+</td>
+</tr>
+</table>
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr width="100%">
+<td align="left" valign="top" width="120">
+<table width="120" cellspacing="0" cellpadding="0" border="0" bgcolor="#a0a0a0">
+<tr>
+<td valign="top" align="left"><img width="120" vspace="0" src="images/join.gif" hspace="0" height="14" border="0"><br>
+</td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="../../index.html">Main</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="../index.html">User Documentation</a></td>
+</tr>
+<tr>
+<td background="images/label-background_b.gif" bgcolor="#959595" valign="top"><img width="120" height="6" src="images/separator.gif"><br>
+<span class="menutitle">XSP</span></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="index.html">Overview</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet.html">XSP Guide</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="xsp-internals.html">XSP Internals</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet-concepts.html">XSP Logicsheets</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><span class="menuselected">Sessions</span></td>
+</tr>
+<tr>
+<td background="images/label-background_b.gif" bgcolor="#959595" valign="top"><img width="120" height="6" src="images/separator.gif"><br>
+<span class="menutitle">Logicsheets</span></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="request.html">Request</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="session.html">Session</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="esql.html">ESQL</a></td>
+</tr>
+<tr>
+<td valign="top" bgcolor="#959595" background="images/label-background_a.gif"><a class="menu" href="logicsheet-forms.html">Forms</a></td>
+</tr>
+<tr>
+<td align="left" valign="top"><img width="120" vspace="0" src="images/close.gif" hspace="0" height="14" border="0"><br>
+</td>
+</tr>
+</table>
+</td><td>
+<table cellspacing="15" cellpadding="0" border="0">
+<tr>
+<td>
+
+
+
+
+ <font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Introduction</font>
+<hr style="color: #0086b2" size="1">
+
+<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>Goal</b></font>
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ Maintaining state is a common problem for web server frameworks
+ because HTTP is a stateless protocol. There are many solutions known
+ to obtain stateful information. Client-side storage of state information
+ like the usage of cookies will not be discussed here, since this depends
+ heavily on the client's browser. Since Cocoon is a server-side framework,
+ storing visitor information at the server side will give full access
+ to the list of all visitors, to what they have done, and what they are
+ doing.
+ </font>
+</p>
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">Please always think a little while if you really want to set up
+ session management. Less scalability and performance is the dark
+ side of keeping user sessions at the server-side. Each user session consumes
+ memory, disk, and CPU, and it is always recommended that you be careful to
+ system resources before wasting it.
+ </font>
+</p>
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ If you decided to set up session tracking, Cocoon offers you:
+ </font>
+</p>
+
+<blockquote>
+<ul>
+
+<li>
+<font face="verdana, helvetica, sans serif">creation of new session IDs</font>
+</li>
+
+<li>
+<font face="verdana, helvetica, sans serif">full session control by the underlying Servlet API 2.2 servlet engine</font>
+</li>
+
+<li>
+<font face="verdana, helvetica, sans serif">cookie- and URI-based session management</font>
+</li>
+
+<li>
+<font face="verdana, helvetica, sans serif">automatic link rewrite if you like your XSP pages to be URI-session-aware</font>
+</li>
+
+</ul>
+</blockquote>
+
+
+
+
+<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>The xsp-session:encode-url template</b></font>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ To enable Cocoon for URI-based session IDs, an XSP template with the name
+ <code><font face="courier, monospaced">xsp-session:encode-url</font></code> will do this for you. It uses the
+ <code><font face="courier, monospaced">encodeURL</font></code> method from the Servlet API which encodes
+ an URL in a way that a session ID is being attached. Consult your
+ servlet engine documentation for information about what the <code><font face="courier, monospaced">encodeURL</font></code>
+ method returns. For example, the Tomcat
+ engine adds a string <code><font face="courier, monospaced">;jsession=</font></code> followed by an MD5 hash
+ to the URL, but only if the client's browser does not accept cookies.
+ </font>
+</p>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">Here is the fragment for the <code><font face="courier, monospaced">xsp-session:encode-url</font></code> from session.xsl:</font>
+</p>
+
+
+<div align="center">
+<table border="0" cellpadding="0" cellspacing="4">
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
+<pre>
+<!-- encode an URL with the session ID -->
+<xsl:template match="xsp-session:encode-url">
+ <xsl:variable name="href">
+ "<xsl:value-of select="@href"/>"
+ </xsl:variable>
+
+ <xsp:element name="a">
+ <xsp:attribute name="href">
+ <xsp:expr>
+ response.encodeURL(String.valueOf(<xsl:copy-of select="$href"/>))
+ </xsp:expr>
+ </xsp:attribute>
+ <xsl:value-of select="."/>
+ </xsp:element>
+
+</xsl:template>
+</pre>
+</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+</table>
+</div>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ As you might wonder, the XSP template constructs a HTML tag <code><font face="courier, monospaced"><a></font></code> with an
+ attribute <code><font face="courier, monospaced">href</font></code> which is enough for most of the cases.
+ Other methods, like XLink, are planned to be supported at a later time when
+ final W3C recommendations are out.
+ </font>
+</p>
+
+
+
+
+<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>Creating new sessions</b></font>
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ The best place of a web site where new sessions should be created is the entry point
+ where all or most of the visitors step in. After creating the session, or
+ retrieving an old session, the visitor is redirected to a start page.
+ In Cocoon, you must edit your sitemap in order to
+ specify this interesting point of session creation.
+ The <code><font face="courier, monospaced">map-redirect-to</font></code>
+ has an extra attribute <code><font face="courier, monospaced">session</font></code>, which can be set to <code><font face="courier, monospaced">true</font></code>
+ or <code><font face="courier, monospaced">false</font></code>. The former will generate a new session ID if needed
+ by invoking the Servlet API method <code><font face="courier, monospaced">session = request.getSession(true)</font></code>,
+ while the latter ignores session ID handling.
+ </font>
+</p>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ How can Cocoon recognize URIs with appended session IDs? The answer is:
+ Cocoon can match a wildcard against your sessionized pages and keeps happy.
+ So please do not forget to append an asterisk '*' to your patterns in the pipelines.
+ </font>
+</p>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ This fragment from <code><font face="courier, monospaced">sitemap.xsl</font></code> shows how you can add a
+ <code><font face="courier, monospaced">map:redirect-to</font></code> to
+ your Cocoon framework with session handling at the root URL for your
+ web application:
+ </font>
+</p>
+
+
+<div align="center">
+<table border="0" cellpadding="0" cellspacing="4">
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
+<pre>
+
+ <map:pipelines>
+ <map:pipeline>
+
+ <map:match pattern="">
+ <map:redirect-to session="true" uri="welcome"/>
+ </map:match>
+
+ <map:match pattern="welcome*">
+ <map:generate type="file" src="site/welcome.xml"/>
+ <map:transform src="stylesheets/welcome.xsl"/>
+ <map:serialize/>
+ </map:match>
+
+ <map:match pattern="**.xsp*">
+ <map:generate type="serverpages" src="site/{1}.xsp"/>
+ <map:transform src="stylesheets/dynamic-page2html.xsl"/>
+ <map:serialize/>
+ </map:match>
+</pre>
+</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+</table>
+</div>
+
+
+
+
+<font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Example</font>
+<hr style="color: #0086b2" size="1">
+
+<font face="verdana, helvetica, sans serif" size="+1" color="#0086b2"><b>A simple XSP page with session ID</b></font>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ Here you can see the source of an XSP example of how the
+ session feature can be used.
+ The example is located in a file named <code><font face="courier, monospaced">sessionpage.xsp</font></code>
+ and it displays the received session ID together with a rewritten
+ link to the page itself. Depending on your browser settings,
+ you will see nothing (because your browser prefers crunching cookies)
+ or a session ID is encoded into the URL. After clicking on the
+ link named "Follow me!", the session ID is taken into the URL, and
+ the session tracking is established.
+ </font>
+</p>
+
+
+<div align="center">
+<table border="0" cellpadding="0" cellspacing="4">
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
+<pre>
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<xsp:page
+ language="java"
+ xmlns:xsp="http://apache.org/xsp"
+ xmlns:xsp-session="http://apache.org/xsp/session/2.0"
+ xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+>
+
+<!-- a simple session page by J&ouml;rg Prante <joerg@7val.com> -->
+
+<page>
+ <title>A Simple URI-based Session Example</title>
+ <content>
+ <para> <xsp-request:get-uri as="xml"/> </para>
+ <para> Session ID = <xsp-session:get-id as="xml"/> </para>
+ <para>
+ Encode URL Test =
+ <xsp-session:encode-url href="sessionpage.xsp">Follow me!</xsp-session:encode-url>
+ </para>
+ </content>
+</page>
+
+</xsp:page>
+</pre>
+</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+</table>
+</div>
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ If you have been successful with installing the session feature and
+ the example file, the following HTML output will be generated by
+ Cocoon from the above <code><font face="courier, monospaced">sessionpage.xsp</font></code> example, which shows
+ how the rewritten link looks like. Please don't ask
+ why the session ID in the generated link is different from yours.
+ </font>
+</p>
+
+
+<div align="center">
+<table border="0" cellpadding="0" cellspacing="4">
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td bgcolor="#ffffff">
+<pre>
+<!DOCTYPE HTML PUBLIC
+ "-//W3C//DTD HTML 4.0//EN"
+ "http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd">
+<html><head><title>
+ A Simple URI Session Example
+ </title></head>
+ <body vlink="blue" link="blue" alink="red" bgcolor="white">
+
+ <h2 style="color: navy; text-align: center">
+ A Simple URI Session Example
+ </h2>
+
+ <content>
+
+ <p align="left"><i>
+ <b xmlns:xsp-response="http://apache.org/xsp/response/2.0"
+ xmlns:xsp-request="http://apache.org/xsp/request/2.0">
+ sessionpage.xsp</b>
+ </i></p>
+
+ <p align="left"><i>
+ Session ID =
+ <xsp-session:id>F3E9575442D1899760A0B231D0042281</xsp-session:id>
+ </i></p>
+
+ <p align="left"><i>
+ Encode URL Test =
+ <a href="sessionpage.xsp;jsessionid=F3E9575442D1899760A0B231D0042281">
+ Follow me!</a>
+ </i></p>
+ </content>
+
+</body></html>
+</pre>
+</td><td width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+<tr>
+<td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td><td height="1" width="1" bgcolor="#0086b2"><img border="0" hspace="0" vspace="0" height="1" width="1" src="images/void.gif"></td>
+</tr>
+</table>
+</div>
+
+
+
+
+
+<font face="verdana, helvetica, sans serif" size="+2" color="#0086b2">Log analysis of sessions</font>
+<hr style="color: #0086b2" size="1">
+
+
+<p>
+<font color="black" face="verdana,helvetica,sanserif">
+ To be done.
+ </font>
+</p>
+
+
+
+
+
+</td>
+</tr>
+</table>
+</td>
+</tr>
+</table>
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td bgcolor="#0086b2"><img width="1" src="images/dot.gif" height="1"></td>
+</tr>
+<tr>
+<td align="center"><font size="-1" face="arial,helvetica,sanserif" color="#0086b2"><i>Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.</i></font></td>
+</tr>
+</table>
+</body>
+</html>