<?xml version="1.0"?>

<?cocoon-process type="xsp"?>

<?cocoon-process type="xslt"?>
<?xml-stylesheet href="sample.xsl" type="text/xsl"?>

<xsp:page
  language="java"
  xmlns:util="http://www.apache.org/1999/XSP/Util"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>
  <page>
    <title>Redirect Example</title>

    <xsp:logic>
      String name = (String) session.getValue("user.name");

      if (name != null) {
        response.sendRedirect("show-name.xml");
        return;
      }

      name = request.getParameter("name");
      if (name != null &amp;&amp; name.length() &gt; 0) {
        session.putValue("user.name", name);
        response.sendRedirect("show-name.xml");
        return;
      }
    </xsp:logic>

    <form method="post">
      <center>
        <p>
          Your name:&#160;
          <input name="name" type="text" size="24"/>
        </p>

        <p>
          <input type="submit" value="Continue"/>
        </p>
      </center>
    </form>

    <p>
      <a href="view-source.xml?filename=redirect.xml">Source Code</a>
    </p>
  </page>
</xsp:page>
