sesscount.xml: Count Session Access XML

<?xml version="1.0"?>

<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sesscount.xsl" type="text/xsl"?>

<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <xsp:structure>
    <xsp:include>java.util.Enumeration</xsp:include>
  </xsp:structure>
  <xsp:logic>
    private static final String textname = "text";
    private static final String countname = "counter";
  </xsp:logic>
  <sesscount>
    <title>
      XML Session Counter
    </title>
    <xsp:logic>
      if (session == null)
        session = request.getSession ();
      Integer count = (Integer) session.getAttribute (countname);
      if (count == null)
        count = new Integer (0);
      String text = request.getParameter (textname);
      if (text == null)
        {
          text = (String) session.getAttribute (textname);
          if (text == null)
            text = "";
        }
      else
        {
          session.setAttribute (textname, text);
          count = new Integer (count.intValue () + 1);
          session.setAttribute (countname, count);
        }
    </xsp:logic>
    <xsp:element name="session">
      <xsp:attribute name="id"><xsp:expr>
        session.getId ()
      </xsp:expr></xsp:attribute>
      <xsp:attribute name="url"><xsp:expr>
        response.encodeURL (request.getRequestURI ())
      </xsp:expr></xsp:attribute>
    </xsp:element>
    <xsp:element name="data">
      <xsp:attribute name="count"><xsp:expr>
        count.intValue ()
      </xsp:expr></xsp:attribute>
      <xsp:attribute name="text"><xsp:expr>text</xsp:expr></xsp:attribute>
    </xsp:element>
    <xsp:element name="names">
      <xsp:attribute name="count"><xsp:expr>countname</xsp:expr></xsp:attribute>
      <xsp:attribute name="text"><xsp:expr>textname</xsp:expr></xsp:attribute>
    </xsp:element>
  </sesscount>
</xsp:page>