You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/03/06 04:05:24 UTC

cvs commit: xml-cocoon2/src/webapp/docs/samples/xsp-js session.xsp

vgritsenko    02/03/05 19:05:24

  Modified:    .        changes.xml
               src/documentation/xdocs/userdocs/xsp session.xml
                        sessions.xml
               src/java/org/apache/cocoon/components/language/markup/xsp
                        JSGenerator.java XSPSessionHelper.java
               src/java/org/apache/cocoon/components/language/markup/xsp/java
                        session.xsl
               src/java/org/apache/cocoon/components/language/markup/xsp/javascript
                        session.xsl
               src/webapp/docs/samples/xsp session.xsp sessionpage.xsp
               src/webapp/docs/samples/xsp-js session.xsp
  Log:
  Process @create-session attribute on the xsp:page element as described in the xsp-session logicsheet documentation.
  
  Revision  Changes    Path
  1.115     +19 -2     xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- changes.xml	4 Mar 2002 17:41:17 -0000	1.114
  +++ changes.xml	6 Mar 2002 03:05:22 -0000	1.115
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.114 2002/03/04 17:41:17 sylvain Exp $
  +  $Id: changes.xml,v 1.115 2002/03/06 03:05:22 vgritsenko Exp $
   -->
   
   <changes title="History of Changes">
  @@ -32,12 +32,26 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="VG" type="update">
  +   Added &lt;xsp:page create-session=""&gt; attribute now processed correctly,
  +   as described in the xsp-session logicsheet documentation. Variable 'session'
  +   declared and could be used in XSP page code.
  +  </action>
     <action dev="SW" type="add">
      New implementation of the sitemap engine based on an evaluation tree. This provides
      super-fast load times (no more compilation), and a slight gain in request processing
      speed compared to the compiled engine thanks to the HotSpot VM.
     </action>
     <action dev="VG" type="add">
  +   Added matchers: HeaderMatcher, ParameterMatcher.
  +  </action>
  +  <action dev="VG" type="add" due-to="Matteo Di Giovinazzo" due-to-email="matteodg@infinito.it">
  +   Added CookieSelector.
  +  </action>
  +  <action dev="VG" type="add" due-to="Maciek Kaminski" due-to-email="maciejka@tiger.com.pl">
  +   Added CookieMatcher.
  +  </action>
  +  <action dev="VG" type="add">
      Request, response, and session XSP logicsheets in Javascript language are added.
     </action>
     <action dev="SM" type="add" due-to="Andreas Hartmann" due-to-email="ah@cocooncenter.de">
  @@ -50,7 +64,10 @@
      Cleaned up documentation and refactored it a little.
     </action>
     <action dev="GR" type="fix">
  -   Started to clean up the XML:DB stuff. The XML:DB generators have been deprecated, and a note has been written in the docs suggesting to switch to the XML:DB pseudo-protocol. Configurations have been switched from dbXML to Xindice.
  +   Started to clean up the XML:DB stuff. The XML:DB generators have been
  +   deprecated, and a note has been written in the docs suggesting to switch
  +   to the XML:DB pseudo-protocol. Configurations have been switched from dbXML
  +   to Xindice.
     </action>
     <action dev="SW" type="add">
      New WriteableSource interface that extends Source. Just as Source for reading,
  
  
  
  1.4       +44 -39    xml-cocoon2/src/documentation/xdocs/userdocs/xsp/session.xml
  
  Index: session.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/xsp/session.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- session.xml	5 Feb 2002 02:49:29 -0000	1.3
  +++ session.xml	6 Mar 2002 03:05:23 -0000	1.4
  @@ -45,7 +45,7 @@
   
   <p>To use the Session logicsheet, you must first declare the <em>session</em>
   namespace, mapping it to the uri <em>http://apache.org/xsp/session/2.0</em>.
  -Also, to ensure that you have a session to work with, you must set the 
  +Also, to ensure that you have a session to work with, you must set the
   <code>create-session</code> attribute in the xsp:page element to true.  This
   will retrieve the existing session, or create a new one if the current one is
   invalid or doesn't exist.  These steps will result in code like this:</p>
  @@ -53,12 +53,13 @@
   <source><![CDATA[
   <xsp:page
     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  -  xmlns:session="http://apache.org/xsp/session/2.0"
  -  create-session="true"
  ->
  +  xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +  create-session="true">
  +
   ...
  +
   </xsp:page>
  -]]></source> 
  +]]></source>
   
   <p>You may then use any of the elements in the <em>session</em> namespace described
   in the <link href="session.html#elements">Elements Reference</link> section below.</p>
  @@ -80,17 +81,18 @@
   
   <xsp:page
     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  -  xmlns:session="http://apache.org/xsp/session/2.0"
  -  create-session="true"
  ->
  +  xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +  create-session="true">
  +
     <html>
  -    <session:set-attribute name="fruit">Apple</session:set-attribute>
  -    <b>Your fruit is:</b> <session:get-attribute name="fruit"/>
  +    <xsp-session:set-attribute name="fruit">Apple</xsp-session:set-attribute>
  +    <b>Your fruit is:</b> <xsp-session:get-attribute name="fruit"/>
       <br/>
  -    <b>Your session was created:</b> <session:get-creation-time as="string"/>
  +    <b>Your session was created:</b> <xsp-session:get-creation-time as="string"/>
     </html>
  +
   </xsp:page>
  -]]></source> 
  +]]></source>
   
   <p>The output of this page should look something like:</p>
   <p><strong>Your fruit is:</strong> Apple</p>
  @@ -112,35 +114,38 @@
   <![CDATA[
   <xsp:page
     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  -  xmlns:session="http://apache.org/xsp/session/2.0"
  -  create-session="true"
  ->
  +  xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +  create-session="true">
  +
     <page>
  -    <session:set-attribute name="fruit">Apple</session:set-attribute>
  -    <fruit><session:get-attribute name="fruit"/></fruit>
  +    <xsp-session:set-attribute name="fruit">Apple</xsp-session:set-attribute>
  +    <fruit><xsp-session:get-attribute name="fruit"/></fruit>
     </page>
  +
   </xsp:page>
  -]]></source> 
  +]]></source>
   
   <source>
   <strong>Using the session object:</strong>
   <![CDATA[
   <xsp:page
     xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  -  create-session="true"
  ->
  +  xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +  create-session="true">
  +
     <page>
       session.setAttribute("fruit", "Apple");
       <fruit><xsp:expr>session.getAttribute("fruit")</xsp:expr></fruit>
     </page>
  +
   </xsp:page>
  -]]></source> 
  +]]></source>
   
   <p>You may freely mix Session elements with other XSP Java code, thus:</p>
   
   <source><![CDATA[
   <xsp:logic>
  -  String fruit = <session:get-attribute name="fruit"/>;
  +  String fruit = <xsp-session:get-attribute name="fruit"/>;
     if (fruit != null) {
       fruit = fruit.toUpperCase();
     }
  @@ -161,11 +166,11 @@
   <p>The following fragments are equivalent:</p>
   
   <source><![CDATA[
  -<session:get-attribute name="fruit"/>
  +<xsp-session:get-attribute name="fruit"/>
   ]]></source> 
   
   <source><![CDATA[
  -<session:get-attribute><name>fruit</name></session:get-attribute>
  +<xsp-session:get-attribute><xsp-session:name>fruit</xsp-session:name></xsp-session:get-attribute>
   ]]></source> 
   
   <p>All Session elements which get data from the session can output the data
  @@ -180,17 +185,17 @@
   the following code fragment:</p>
   
   <source><![CDATA[
  -<session:get-attribute as="node" name="fruit"/>
  +<xsp-session:get-attribute as="node" name="fruit"/>
   ]]></source> 
   
   <p>results in output similar to:</p>
   
   <source><![CDATA[
  -<session:attribute name="fruit">apple</session:attribute>
  +<xsp-session:attribute name="fruit">apple</xsp-session:attribute>
   ]]></source> 
   
   <p>This is especially useful with elements that return multiple pieces of
  -information, such as <code>session:get-attribute-names</code>.  Without using 
  +information, such as <code>xsp-session:get-attribute-names</code>.  Without using
   <code>as="node"</code>, the returned values are written out end to end
   without separation.  If node output is requested, however, each value
   is written out in a separate node, which may then be referenced separately.</p>
  @@ -218,21 +223,21 @@
   </tr>
   
   <tr>
  -<td>session:get-attribute</td>
  +<td>xsp-session:get-attribute</td>
   <td>name</td>
   <td>yes</td>
   <td>Gets the value of the named attribute stored in the session.</td>
   </tr>
   
   <tr>
  -<td>session:get-attribute-names</td>
  +<td>xsp-session:get-attribute-names</td>
   <td></td>
   <td>yes</td>
   <td>Gets the names of all attributes stored in the session.</td>
   </tr>
   
   <tr>
  -<td>session:get-creation-time</td>
  +<td>xsp-session:get-creation-time</td>
   <td></td>
   <td>yes</td>
   <td>Gets the time when this session was created. The <code>as</code> attribute
  @@ -244,14 +249,14 @@
   </tr>
   
   <tr>
  -<td>session:get-id</td>
  +<td>xsp-session:get-id</td>
   <td></td>
   <td>yes</td>
   <td>Gets the session id, generally a randomly generated string (server dependent).</td>
   </tr>
   
   <tr>
  -<td>session:get-last-accessed-time</td>
  +<td>xsp-session:get-last-accessed-time</td>
   <td></td>
   <td>yes</td>
   <td>Gets the last time this session was accessed (the last time a page was
  @@ -264,7 +269,7 @@
   </tr>
   
   <tr>
  -<td>session:get-max-inactive-interval</td>
  +<td>xsp-session:get-max-inactive-interval</td>
   <td></td>
   <td>yes</td>
   <td>Gets the minimum time, in seconds, that the server will maintain 
  @@ -272,7 +277,7 @@
   </tr>
   
   <tr>
  -<td>session:invalidate</td>
  +<td>xsp-session:invalidate</td>
   <td></td>
   <td>no</td>
   <td>Invalidates the current session.  Any attributes stored in the session
  @@ -280,30 +285,30 @@
   </tr>
   
   <tr>
  -<td>session:is-new</td>
  +<td>xsp-session:is-new</td>
   <td></td>
   <td>yes</td>
   <td>Indicates whether this session was just created.</td>
   </tr>
   
   <tr>
  -<td>session:remove-attribute</td>
  +<td>xsp-session:remove-attribute</td>
   <td>name</td>
   <td>no</td>
   <td>Removes the named attribute from the session.</td>
   </tr>
   
   <tr>
  -<td>session:set-attribute</td>
  +<td>xsp-session:set-attribute</td>
   <td>name</td>
   <td>no</td>
   <td>Stores a named attribute in the session. Place the value
   to be stored as the text contents of this element, e.g.,
  -&lt;session:set-attribute name="fruit">apple&lt;/session:set-attribute>.</td>
  +&lt;xsp-session:set-attribute name="fruit">apple&lt;/xsp-session:set-attribute>.</td>
   </tr>
   
   <tr>
  -<td>session:set-max-inactive-interval</td>
  +<td>xsp-session:set-max-inactive-interval</td>
   <td>interval</td>
   <td>no</td>
   <td>Set the minimum time, in seconds, that the server should
  
  
  
  1.3       +7 -7      xml-cocoon2/src/documentation/xdocs/userdocs/xsp/sessions.xml
  
  Index: sessions.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/userdocs/xsp/sessions.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sessions.xml	5 Feb 2002 01:46:45 -0000	1.2
  +++ sessions.xml	6 Mar 2002 03:05:23 -0000	1.3
  @@ -56,11 +56,11 @@
            </s2>
   
   
  -        <s2 title="The session:encode-url template">
  +        <s2 title="The xsp-session:encode-url template">
   
           <p>
           To enable Cocoon for URI-based session IDs, an XSP template with the name
  -        <code>session:encode-url</code> will do this for you. It uses the
  +        <code>xsp-session:encode-url</code> will do this for you. It uses the
           <code>encodeURL</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>encodeURL</code>
  @@ -69,11 +69,11 @@
           to the URL, but only if the client's browser does not accept cookies.
           </p>
   
  -        <p>Here is the fragment for the <code>session:encode-url</code> from session.xsl:</p>
  +        <p>Here is the fragment for the <code>xsp-session:encode-url</code> from session.xsl:</p>
   
   <source><![CDATA[
   <!-- encode an URL with the session ID -->
  -<xsl:template match="session:encode-url">
  +<xsl:template match="xsp-session:encode-url">
     <xsl:variable name="href">
         "<xsl:value-of select="@href"/>"
     </xsl:variable>
  @@ -181,10 +181,10 @@
     <title>A Simple URI-based Session Example</title>
     <content>
       <para> <xsp-request:get-uri as="xml"/> </para>
  -    <para> Session ID = <session:get-id as="xml"/> </para>
  +    <para> Session ID = <xsp-session:get-id as="xml"/> </para>
       <para>
         Encode URL Test =
  -      <session:encode-url href="sessionpage.xsp">Follow me!</session:encode-url>
  +      <xsp-session:encode-url href="sessionpage.xsp">Follow me!</xsp-session:encode-url>
       </para>
     </content>
   </page>
  @@ -223,7 +223,7 @@
   
     <p align="left"><i>
        Session ID =
  -     <session:id>F3E9575442D1899760A0B231D0042281</session:id>
  +     <xsp-session:id>F3E9575442D1899760A0B231D0042281</xsp-session:id>
     </i></p>
   
     <p align="left"><i>
  
  
  
  1.7       +6 -10     xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/JSGenerator.java
  
  Index: JSGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/JSGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JSGenerator.java	28 Feb 2002 14:41:07 -0000	1.6
  +++ JSGenerator.java	6 Mar 2002 03:05:23 -0000	1.7
  @@ -57,11 +57,8 @@
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.language.LanguageException;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.environment.Response;
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.generation.AbstractServerPage;
  +import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.xml.XMLizable;
   
   import org.mozilla.javascript.Context;
  @@ -83,7 +80,6 @@
   import java.util.Map;
   import java.text.ParseException;
   import java.text.DateFormat;
  -import java.text.SimpleDateFormat;
   
   /**
    * Class representing interpreted XSP-generated
  @@ -91,7 +87,7 @@
    * written in Javascript language
    *
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: JSGenerator.java,v 1.6 2002/02/28 14:41:07 vgritsenko Exp $
  + * @version CVS $Id: JSGenerator.java,v 1.7 2002/03/06 03:05:23 vgritsenko Exp $
    */
   public class JSGenerator extends XSPGenerator
           implements Configurable, Initializable {
  @@ -423,12 +419,12 @@
       }
   
       // XSPSessionHelper
  -    public Object getSessionAttribute(String name, Object defaultValue) {
  -        return XSPSessionHelper.getSessionAttribute(this.objectModel, name, defaultValue);
  +    public Object getSessionAttribute(Session session, String name, Object defaultValue) {
  +        return XSPSessionHelper.getSessionAttribute(session, name, defaultValue);
       }
   
  -    public String[] getSessionAttributeNames() {
  -        Collection c = XSPSessionHelper.getSessionAttributeNames(this.objectModel);
  +    public String[] getSessionAttributeNames(Session session) {
  +        Collection c = XSPSessionHelper.getSessionAttributeNames(session);
           return (String[])c.toArray(new String[c.size()]);
       }
   }
  
  
  
  1.9       +9 -10     xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPSessionHelper.java
  
  Index: XSPSessionHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPSessionHelper.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XSPSessionHelper.java	28 Feb 2002 14:41:07 -0000	1.8
  +++ XSPSessionHelper.java	6 Mar 2002 03:05:23 -0000	1.9
  @@ -69,7 +69,7 @@
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: XSPSessionHelper.java,v 1.8 2002/02/28 14:41:07 vgritsenko Exp $
  + * @version CVS $Id: XSPSessionHelper.java,v 1.9 2002/03/06 03:05:23 vgritsenko Exp $
    */
   public class XSPSessionHelper {
   
  @@ -77,16 +77,13 @@
        * Return the given session attribute value or a user-provided default if
        * none was specified.
        *
  -     * @param objectModel The Map objectModel
  +     * @param session The Session object
        * @param name The parameter name
        * @param defaultValue Value to substitute in absence of a parameter value
        */
  -    public static Object getSessionAttribute(Map objectModel, String name,
  +    public static Object getSessionAttribute(Session session, String name,
                                                Object defaultValue) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        Session session = request.getSession(false);
           Object value = null;
  -
           if (session != null) {
               value = session.getAttribute(name);
           }
  @@ -101,12 +98,14 @@
       /**
        * Get the session attribute names.
        *
  -     * @param objectModel The Map objectModel
  +     * @param session The Session object
        */
  -    public static List getSessionAttributeNames(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +    public static List getSessionAttributeNames(Session session) {
           ArrayList v = new ArrayList();
  -        Enumeration e = request.getSession().getAttributeNames();
  +        if (session == null) {
  +            return v;
  +        }
  +        Enumeration e = session.getAttributeNames();
           while (e.hasMoreElements()) {
               v.add(e.nextElement());
           }
  
  
  
  1.13      +48 -31    xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/session.xsl
  
  Index: session.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/session.xsl,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- session.xsl	1 Mar 2002 15:21:24 -0000	1.12
  +++ session.xsl	6 Mar 2002 03:05:23 -0000	1.13
  @@ -1,6 +1,6 @@
   <?xml version="1.0"?>
   
  -<!-- $Id: session.xsl,v 1.12 2002/03/01 15:21:24 vgritsenko Exp $-->
  +<!-- $Id: session.xsl,v 1.13 2002/03/06 03:05:23 vgritsenko Exp $-->
   <!--
   
    ============================================================================
  @@ -56,7 +56,7 @@
    *
    * @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
    * @author ported by <a href="mailto:bloritsch@apache.org>Berin Loritsch</a>
  - * @version CVS $Revision: 1.12 $ $Date: 2002/03/01 15:21:24 $
  + * @version CVS $Revision: 1.13 $ $Date: 2002/03/06 03:05:23 $
   -->
   
   <xsl:stylesheet version="1.0"
  @@ -65,6 +65,28 @@
     xmlns:xsp-session="http://apache.org/xsp/session/2.0">
   
     <!-- *** ServletSession Templates *** -->
  +  <xsl:template match="xsp:page">
  +    <xsp:page>
  +      <xsl:apply-templates select="@*"/>
  +
  +      <xsp:structure>
  +        <xsp:include>org.apache.cocoon.environment.Session</xsp:include>
  +      </xsp:structure>
  +
  +      <xsl:variable name="create">
  +        <xsl:choose>
  +          <xsl:when test="@create-session='yes' or @create-session='true'">true</xsl:when>
  +          <xsl:when test="@create-session='no' or @create-session='false'">false</xsl:when>
  +          <xsl:otherwise>true</xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:variable>
  +      <xsp:init-page>
  +        Session session = request.getSession(<xsl:value-of select="$create"/>);
  +      </xsp:init-page>
  +
  +      <xsl:apply-templates/>
  +    </xsp:page>
  +  </xsl:template>
   
     <xsl:template match="xsp-session:get-session-id">
       <xsl:variable name="as">
  @@ -74,14 +96,12 @@
       </xsl:variable>
       <xsl:choose>
         <xsl:when test="$as = 'string'">
  -        <xsp:expr>
  -          (request.getSession().getId())
  -        </xsp:expr>
  +        <xsp:expr> (session.getId()) </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'xml'">
           <!-- <xsp-session:session-id> -->
           <xsp:element name="xsp-session:session-id">
  -          <xsp:expr>request.getSession().getId()</xsp:expr>
  +          <xsp:expr>session.getId()</xsp:expr>
           </xsp:element>
         </xsl:when>
       </xsl:choose>
  @@ -111,7 +131,7 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:attribute">
             <xsp:expr>
  -            XSPSessionHelper.getSessionAttribute(objectModel,
  +            XSPSessionHelper.getSessionAttribute(session,
               String.valueOf(<xsl:copy-of select="$name"/>),
               <xsl:copy-of select="$default"/>)
             </xsp:expr>
  @@ -119,7 +139,7 @@
         </xsl:when>
         <xsl:when test="$as = 'object'">
           <xsp:expr>
  -          XSPSessionHelper.getSessionAttribute(objectModel,
  +          XSPSessionHelper.getSessionAttribute(session,
             String.valueOf(<xsl:copy-of select="$name"/>),
             <xsl:copy-of select="$default"/>)
           </xsp:expr>
  @@ -136,7 +156,7 @@
       <xsl:choose>
         <xsl:when test="$as = 'xml'">
           <xsp:logic>
  -          List v = XSPSessionHelper.getSessionAttributeNames(objectModel);
  +          List v = XSPSessionHelper.getSessionAttributeNames(session);
           </xsp:logic>
           <xsp:element name="xsp-session:attribute-names">
             <xsp:logic>
  @@ -150,7 +170,7 @@
         </xsl:when>
         <xsl:when test="$as = 'array'">
           <xsp:expr>
  -          XSPSessionHelper.getSessionAttributeNames(objectModel)
  +          XSPSessionHelper.getSessionAttributeNames(session)
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -166,18 +186,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:creation-time">
             <xsp:expr>
  -            new Date(request.getSession().getCreationTime())
  +            new Date(session.getCreationTime())
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          new Date(request.getSession().getCreationTime())
  +          new Date(session.getCreationTime())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'long'">
           <xsp:expr>
  -          request.getSession().getCreationTime()
  +          session.getCreationTime()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -192,11 +212,11 @@
       <xsl:choose>
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:id">
  -          <xsp:expr>request.getSession().getId()</xsp:expr>
  +          <xsp:expr>session.getId()</xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
  -        <xsp:expr>request.getSession().getId()</xsp:expr>
  +        <xsp:expr>session.getId()</xsp:expr>
         </xsl:when>
       </xsl:choose>
     </xsl:template>
  @@ -211,18 +231,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:last-accessed-time">
             <xsp:expr>
  -            new Date(request.getSession().getLastAccessedTime())
  +            new Date(session.getLastAccessedTime())
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          new Date(request.getSession().getLastAccessedTime())
  +          new Date(session.getLastAccessedTime())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'long'">
           <xsp:expr>
  -          request.getSession().getLastAccessedTime()
  +          session.getLastAccessedTime()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -239,18 +259,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:max-inactive-interval">
             <xsp:expr>
  -            request.getSession().getMaxInactiveInterval()
  +            session.getMaxInactiveInterval()
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          String.valueOf(request.getSession().getMaxInactiveInterval())
  +          String.valueOf(session.getMaxInactiveInterval())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'int'">
           <xsp:expr>
  -          request.getSession().getMaxInactiveInterval()
  +          session.getMaxInactiveInterval()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -258,7 +278,7 @@
   
     <xsl:template match="xsp-session:invalidate">
       <xsp:logic>
  -      request.getSession().invalidate();
  +      session.invalidate();
       </xsp:logic>
     </xsl:template>
   
  @@ -272,14 +292,14 @@
         <xsl:choose>
           <xsl:when test="$as = 'xml'">
             <xsp:element name="xsp-session:is-new">
  -            <xsp:expr>request.getSession().isNew()</xsp:expr>
  +            <xsp:expr>session.isNew()</xsp:expr>
             </xsp:element>
           </xsl:when>
           <xsl:when test="$as = 'string'">
  -          <xsp:expr>String.valueOf(request.getSession().isNew())</xsp:expr>
  +          <xsp:expr>String.valueOf(session.isNew())</xsp:expr>
           </xsl:when>
           <xsl:when test="$as = 'boolean'">
  -          <xsp:expr>request.getSession().isNew()</xsp:expr>
  +          <xsp:expr>session.isNew()</xsp:expr>
           </xsl:when>
         </xsl:choose>
       </xsp:expr>
  @@ -290,7 +310,7 @@
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
       <xsp:logic>
  -      request.getSession().removeAttribute(String.valueOf(<xsl:copy-of select="$name"/>));
  +      session.removeAttribute(String.valueOf(<xsl:copy-of select="$name"/>));
       </xsp:logic>
     </xsl:template>
   
  @@ -304,8 +324,7 @@
         </xsl:call-template>
       </xsl:variable>
       <xsp:logic>
  -      request.getSession().setAttribute(
  -          String.valueOf(<xsl:copy-of select="$name"/>),
  +      session.setAttribute(String.valueOf(<xsl:copy-of select="$name"/>),
             <xsl:copy-of select="$content"/>);
       </xsp:logic>
     </xsl:template>
  @@ -323,9 +342,7 @@
         </xsl:choose>
       </xsl:variable>
       <xsp:logic>
  -      request.getSession().setMaxInactiveInterval(
  -          Integer.parseInt(String.valueOf(<xsl:copy-of select="$interval"/>))
  -      );
  +      session.setMaxInactiveInterval(Integer.parseInt(String.valueOf(<xsl:copy-of select="$interval"/>)));
       </xsp:logic>
     </xsl:template>
   
  
  
  
  1.3       +46 -34    xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/javascript/session.xsl
  
  Index: session.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/javascript/session.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- session.xsl	1 Mar 2002 15:21:24 -0000	1.2
  +++ session.xsl	6 Mar 2002 03:05:23 -0000	1.3
  @@ -1,6 +1,6 @@
   <?xml version="1.0"?>
   
  -<!-- $Id: session.xsl,v 1.2 2002/03/01 15:21:24 vgritsenko Exp $-->
  +<!-- $Id: session.xsl,v 1.3 2002/03/06 03:05:23 vgritsenko Exp $-->
   <!--
   
    ============================================================================
  @@ -57,7 +57,7 @@
    * @author <a href="mailto:ricardo@apache.org>Ricardo Rocha</a>
    * @author ported by <a href="mailto:bloritsch@apache.org>Berin Loritsch</a>
    * @author ported by <a href="mailto:vgritsenko@apache.org>Vadim Gritsenko</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/03/01 15:21:24 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/03/06 03:05:23 $
   -->
   
   <xsl:stylesheet version="1.0"
  @@ -66,6 +66,24 @@
     xmlns:xsp-session="http://apache.org/xsp/session/2.0">
   
     <!-- *** ServletSession Templates *** -->
  +  <xsl:template match="xsp:page">
  +    <xsp:page>
  +      <xsl:apply-templates select="@*"/>
  +
  +      <xsl:variable name="create">
  +        <xsl:choose>
  +          <xsl:when test="@create-session='yes' or @create-session='true'">true</xsl:when>
  +          <xsl:when test="@create-session='no' or @create-session='false'">false</xsl:when>
  +          <xsl:otherwise>true</xsl:otherwise>
  +        </xsl:choose>
  +      </xsl:variable>
  +      <xsp:init-page>
  +        var session = request.getSession(<xsl:value-of select="$create"/>);
  +      </xsp:init-page>
  +
  +      <xsl:apply-templates/>
  +    </xsp:page>
  +  </xsl:template>
   
     <xsl:template match="xsp-session:get-session-id">
       <xsl:variable name="as">
  @@ -75,16 +93,12 @@
       </xsl:variable>
       <xsl:choose>
         <xsl:when test="$as = 'string'">
  -        <xsp:expr>
  -          (request.getSession().getId())
  -        </xsp:expr>
  +        <xsp:expr> (session.getId()) </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'xml'">
           <!-- <xsp-session:session-id> -->
           <xsp:element name="xsp-session:session-id">
  -          <xsp:expr>
  -            (request.getSession().getId())
  -          </xsp:expr>
  +          <xsp:expr>session.getId()</xsp:expr>
           </xsp:element>
         </xsl:when>
       </xsl:choose>
  @@ -114,15 +128,15 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:attribute">
             <xsp:expr>
  -            page.getSessionAttribute(String(<xsl:copy-of select="$name"/>),
  -            <xsl:copy-of select="$default"/>)
  +            page.getSessionAttribute(session, String(<xsl:copy-of select="$name"/>),
  +                <xsl:copy-of select="$default"/>)
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'object'">
           <xsp:expr>
  -          page.getSessionAttribute(String(<xsl:copy-of select="$name"/>),
  -          <xsl:copy-of select="$default"/>)
  +          page.getSessionAttribute(session, String(<xsl:copy-of select="$name"/>),
  +              <xsl:copy-of select="$default"/>)
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -138,7 +152,7 @@
       <xsl:choose>
         <xsl:when test="$as = 'xml'">
           <xsp:logic>
  -          _session_attribute_names_ = page.getSessionAttributeNames();
  +          _session_attribute_names_ = page.getSessionAttributeNames(session);
           </xsp:logic>
           <xsp:element name="xsp-session:attribute-names">
             <xsp:logic>
  @@ -153,7 +167,7 @@
   
         <xsl:when test="$as = 'array'">
           <xsp:expr>
  -          page.getSessionAttributeNames()
  +          page.getSessionAttributeNames(session)
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -170,18 +184,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:creation-time">
             <xsp:expr>
  -            Date(request.getSession().getCreationTime())
  +            Date(session.getCreationTime())
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          Date(request.getSession().getCreationTime())
  +          Date(session.getCreationTime())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'long'">
           <xsp:expr>
  -          request.getSession().getCreationTime()
  +          session.getCreationTime()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -196,11 +210,11 @@
       <xsl:choose>
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:id">
  -          <xsp:expr>request.getSession().getId()</xsp:expr>
  +          <xsp:expr>session.getId()</xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
  -        <xsp:expr>request.getSession().getId()</xsp:expr>
  +        <xsp:expr>session.getId()</xsp:expr>
         </xsl:when>
       </xsl:choose>
     </xsl:template>
  @@ -215,18 +229,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:last-accessed-time">
             <xsp:expr>
  -            Date(request.getSession().getLastAccessedTime())
  +            Date(session.getLastAccessedTime())
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          Date(request.getSession().getLastAccessedTime())
  +          Date(session.getLastAccessedTime())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'long'">
           <xsp:expr>
  -          request.getSession().getLastAccessedTime()
  +          session.getLastAccessedTime()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -243,18 +257,18 @@
         <xsl:when test="$as = 'xml'">
           <xsp:element name="xsp-session:max-inactive-interval">
             <xsp:expr>
  -            request.getSession().getMaxInactiveInterval()
  +            session.getMaxInactiveInterval()
             </xsp:expr>
           </xsp:element>
         </xsl:when>
         <xsl:when test="$as = 'string'">
           <xsp:expr>
  -          String(request.getSession().getMaxInactiveInterval())
  +          String(session.getMaxInactiveInterval())
           </xsp:expr>
         </xsl:when>
         <xsl:when test="$as = 'int'">
           <xsp:expr>
  -          request.getSession().getMaxInactiveInterval()
  +          session.getMaxInactiveInterval()
           </xsp:expr>
         </xsl:when>
       </xsl:choose>
  @@ -262,7 +276,7 @@
   
     <xsl:template match="xsp-session:invalidate">
       <xsp:logic>
  -      request.getSession().invalidate();
  +      session.invalidate();
       </xsp:logic>
     </xsl:template>
   
  @@ -276,14 +290,14 @@
         <xsl:choose>
           <xsl:when test="$as = 'xml'">
             <xsp:element name="xsp-session:is-new">
  -            <xsp:expr>request.getSession().isNew()</xsp:expr>
  +            <xsp:expr>session.isNew()</xsp:expr>
             </xsp:element>
           </xsl:when>
           <xsl:when test="$as = 'string'">
  -          <xsp:expr>String(request.getSession().isNew())</xsp:expr>
  +          <xsp:expr>String(session.isNew())</xsp:expr>
           </xsl:when>
           <xsl:when test="$as = 'boolean'">
  -          <xsp:expr>request.getSession().isNew()</xsp:expr>
  +          <xsp:expr>session.isNew()</xsp:expr>
           </xsl:when>
         </xsl:choose>
       </xsp:expr>
  @@ -294,7 +308,7 @@
         <xsl:call-template name="value-for-name"/>
       </xsl:variable>
       <xsp:logic>
  -      request.getSession().removeAttribute(String(<xsl:copy-of select="$name"/>));
  +      session.removeAttribute(String(<xsl:copy-of select="$name"/>));
       </xsp:logic>
     </xsl:template>
   
  @@ -308,8 +322,7 @@
         </xsl:call-template>
       </xsl:variable>
       <xsp:logic>
  -      request.getSession().setAttribute(
  -          String(<xsl:copy-of select="$name"/>),
  +      session.setAttribute(String(<xsl:copy-of select="$name"/>),
             <xsl:copy-of select="$content"/>);
       </xsp:logic>
     </xsl:template>
  @@ -326,9 +339,8 @@
           <xsl:otherwise>0</xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
  -
       <xsp:logic>
  -      request.getSession().setMaxInactiveInterval(String(<xsl:copy-of select="$interval"/>));
  +      session.setMaxInactiveInterval(String(<xsl:copy-of select="$interval"/>));
       </xsp:logic>
     </xsl:template>
   
  
  
  
  1.4       +4 -3      xml-cocoon2/src/webapp/docs/samples/xsp/session.xsp
  
  Index: session.xsp
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/xsp/session.xsp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- session.xsp	28 Feb 2002 14:42:22 -0000	1.3
  +++ session.xsp	6 Mar 2002 03:05:23 -0000	1.4
  @@ -1,10 +1,11 @@
   <?xml version="1.0" encoding="iso-8859-1"?>
   
  -<!-- CVS: $Id: session.xsp,v 1.3 2002/02/28 14:42:22 vgritsenko Exp $ -->
  +<!-- CVS: $Id: session.xsp,v 1.4 2002/03/06 03:05:23 vgritsenko Exp $ -->
   
   <xsp:page language="java"
  -	  xmlns:xsp="http://apache.org/xsp"
  -	  xmlns:xsp-session="http://apache.org/xsp/session/2.0">
  +          xmlns:xsp="http://apache.org/xsp"
  +          xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +          create-session="yes">
     
   <page>
   
  
  
  
  1.2       +5 -4      xml-cocoon2/src/webapp/docs/samples/xsp/sessionpage.xsp
  
  Index: sessionpage.xsp
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/xsp/sessionpage.xsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sessionpage.xsp	21 Feb 2002 03:02:09 -0000	1.1
  +++ sessionpage.xsp	6 Mar 2002 03:05:23 -0000	1.2
  @@ -1,11 +1,12 @@
   <?xml version="1.0" encoding="iso-8859-1"?>
   
  -<!-- CVS: $Id: sessionpage.xsp,v 1.1 2002/02/21 03:02:09 vgritsenko Exp $ -->
  +<!-- CVS: $Id: sessionpage.xsp,v 1.2 2002/03/06 03:05:23 vgritsenko Exp $ -->
   
   <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">
  +          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"
  +          create-session="yes">
     
     <!-- a simple session page by J�rg Prante <jo...@7val.com> -->
     
  
  
  
  1.2       +4 -3      xml-cocoon2/src/webapp/docs/samples/xsp-js/session.xsp
  
  Index: session.xsp
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/xsp-js/session.xsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- session.xsp	28 Feb 2002 14:53:41 -0000	1.1
  +++ session.xsp	6 Mar 2002 03:05:23 -0000	1.2
  @@ -1,10 +1,11 @@
   <?xml version="1.0" encoding="iso-8859-1"?>
   
  -<!-- CVS: $Id: session.xsp,v 1.1 2002/02/28 14:53:41 vgritsenko Exp $ -->
  +<!-- CVS: $Id: session.xsp,v 1.2 2002/03/06 03:05:23 vgritsenko Exp $ -->
   
   <xsp:page language="java"
  -	  xmlns:xsp="http://apache.org/xsp"
  -	  xmlns:xsp-session="http://apache.org/xsp/session/2.0">
  +          xmlns:xsp="http://apache.org/xsp"
  +          xmlns:xsp-session="http://apache.org/xsp/session/2.0"
  +          create-session="yes">
     
   <page>
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org