Hi Markus,

first of all make sure that you have no blank before .setAttribute

      request .setAttribute ("hello", "world");

But this could be caused by the mailer.

You can get the request within an xsp by accessing the "request" variable in
this way:

<xsp:page>
<xsp:structure>
  <xsp:include>org.apache.cocoon.environment.Request</xsp:include>
</xsp:structure>

<xy>
  <xsp:logic>
    Object theAttribute = request.getAttribute(...);
  </xsp:logic>
</xy>
</xsp:page>

Best regards
- Volker -

-----Original Message-----
From: Markus Locher, ASK Keller GmbH
[mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 14. Mai 2002 15:06
To: Cocoon Mailinglist
Subject: Canīt get Request from an Action


Hello Folks,

I added a self-developed action to org/apache/cocoon with a path from there
like ask/auth. Under auth I have created a servlet called Login.java. You
guessed!.. I am trying to create a login-action for internal use (I know
there is a sample, but that doesnīt fit our needs).

The Login-Servlet gives me a Map back (nothing new) and it sets an attribute
to a Request like ...

   Request.setAttribute("hello","world");

as in the docs from Cocoon!!! "Creating and Using Actions".

The value of the Map is read successfully in the sitemap.xmap, but the
request values can't be read out within an xsp-page. Got only null.

What's wrong?
--------------------------------Login.java----------------
package org.apache.cocoon.ask.auth;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.Constants;
import java.util.Map;
import java.util.HashMap;
import org.apache.cocoon.environment.*;
import org.xml.sax.EntityResolver;

public class Login extends  AbstractAction
     implements  ThreadSafe {

  public Map act (Redirector   redirector,
                  SourceResolver resolver,
                  Map     objectModel,
                  String   source,
                  Parameters   params
   ) {

    Map  sitemapParams  = new HashMap();
      sitemapParams .put ("authArt", "login");

    Request  request = (Request) objectModel.get (Constants.REQUEST_OBJECT);
      request .setAttribute ("hello", "world");


   return sitemapParams;
  }
}
--------------------------------login.xsp----------------
...
<para><xsp-request:get-attribute name="hello"/></para>
...
The rest of xsp-page is correct.
--------------------------------login.xsl----------------
...
 <p><xsl:value-of select="//para"/></p> <br/>
... Rest OK.
--------------------------------sitemap.xmap----------------
...
<map:actions>
     <map:action name = "xifs-login"
        src  = "org.apache.cocoon.ask.auth.Login"/>
  </map:actions>
... within a pipeline!!!
<!-- SERVLETS -->
  <map:match pattern="auth/**">
      <!-- Performe login ... -->
      <map:act type="xifs-login">

    <map:generate type="serverpages" src="../xsp/login.xsp"/>
    <map:transform src="../styles/login.xsl"/>
     <map:serialize/>

     </map:act>

      <!-- If all fails ...-->
      <map:redirect-to uri="../welcome"/>

   </map:match>

...

Thanks for any help.

Regards Markus
mailto:[EMAIL PROTECTED]





---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to