cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Christophe Kermagoret <...@babelobjects.com>
Subject Re: Access servlet context attribute: how?
Date Thu, 01 Apr 2004 07:48:06 GMT
Mark Lundquist wrote:

> OK, so I would like to pass a parameter in to my Cocoon application 
> via a context attribute (because I can set that in my Jetty 
> configuration file).  How do I access a context attribute from within 
> one of my Java classes?
>
> Thx-a-lot,
> mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
Hi Mark,
have you tried something like that ? It's a javascript code but java 
code is almost the same.

/**
  * Example :
  *  getContextValue("authentication","/authentication/ID");
  *  getContextValue("authentication","/authentication/role");
  *  getContextValue("authentication","/authentication/data/user");
  **/
 
function getContextValue(contextPath, path) {
    var contextMan =
        
cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
    var context = contextMan.getContext(contextPath);

    return context.getXML(path).getTextContent();
}

-- 

Jean-Christophe Kermagoret
jck@BabelObjects.Com




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message