You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robby Pelssers <ro...@ciber.com> on 2009/06/24 15:37:30 UTC

how to access HttpRequest from java in cocoon

Hi guys,

 

Small question...

 

Is there a way to access org.apache.cocoon.environment.http.HttpRequest
from java without having to pass the request object from flowscript to
my java class like the snippet below?

 

 

importClass(Packages.com.xxx.xxx.UserFactoryImpl);

 

function main() {

    var factory = new UserFactoryImpl();

    var user = factory.getUser(cocoon.request, userId);

           ...

}

 

Thx in advance,

Robby

 


RE: how to access HttpRequest from java in cocoon

Posted by Robby Pelssers <ro...@ciber.com>.
Thx Andre,

I googled around based on your answer and declaring a spring dependency
seems to be the correct answer ;-)

Just for the record... This class
"org.apache.cocoon.processing.impl.ProcessInfoProviderImpl " is part of
the sitemap-impl module.

http://cocoon.apache.org/2.2/core-modules/sitemap-impl/1.0/apidocs/index
.html


Thx,
Robby


-----Original Message-----
From: Andre Juffer [mailto:ajuffer@sun3.oulu.fi] 
Sent: Wednesday, June 24, 2009 8:40 PM
To: users@cocoon.apache.org
Subject: Re: how to access HttpRequest from java in cocoon

Hi Robby,

If you just want to get to the javax.servlet.http.HttpServletRequest, 
with Java you can do the following (see below). I have used this for 
some time now with Cocoon 2.2. The class SomeClass is instantiated as 
Singleton with Spring. It provides access to both the Session and 
Request object. Works very well.


import org.apache.cocoon.processing.*;
import javax.servlet.http.*;

public class SomeClass {

     private ProcessInfoProvider processInfoProvider;
     .....

     public SomeClass()
     {
         this.processInfoProvider = null;
         .....
     }

     public void setProcessInfoProvider(ProcessInfoProvider 
processInfoProvider)
     {
         this.processInfoProvider = processInfoProvider;
     }

     .....

     public void doSomething()
     {
         HttpServletRequest request =
this.processInfoProvider.getRequest();
         HttpSession session = request.getSession(false);
         ....
     }
}

Robby Pelssers wrote:
> Hi guys,
> 
>  
> 
> Small question...
> 
>  
> 
> Is there a way to access
org.apache.cocoon.environment.http.HttpRequest 
> from java without having to pass the request object from flowscript to

> my java class like the snippet below?
> 
>  
> 
>  
> 
> importClass(Packages.com.xxx.xxx.UserFactoryImpl);
> 
>  
> 
> function main() {
> 
>     *var* factory = *new* UserFactoryImpl();
> 
>     var user = factory.getUser(cocoon.request, userId);
> 
>            ...
> 
> }
> 
>  
> 
> Thx in advance,
> 
> Robby
> 
>  
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com

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


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


Re: how to access HttpRequest from java in cocoon

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Hi Robby,

If you just want to get to the javax.servlet.http.HttpServletRequest, 
with Java you can do the following (see below). I have used this for 
some time now with Cocoon 2.2. The class SomeClass is instantiated as 
Singleton with Spring. It provides access to both the Session and 
Request object. Works very well.


import org.apache.cocoon.processing.*;
import javax.servlet.http.*;

public class SomeClass {

     private ProcessInfoProvider processInfoProvider;
     .....

     public SomeClass()
     {
         this.processInfoProvider = null;
         .....
     }

     public void setProcessInfoProvider(ProcessInfoProvider 
processInfoProvider)
     {
         this.processInfoProvider = processInfoProvider;
     }

     .....

     public void doSomething()
     {
         HttpServletRequest request = this.processInfoProvider.getRequest();
         HttpSession session = request.getSession(false);
         ....
     }
}

Robby Pelssers wrote:
> Hi guys,
> 
>  
> 
> Small question…
> 
>  
> 
> Is there a way to access org.apache.cocoon.environment.http.HttpRequest 
> from java without having to pass the request object from flowscript to 
> my java class like the snippet below?
> 
>  
> 
>  
> 
> importClass(Packages.com.xxx.xxx.UserFactoryImpl);
> 
>  
> 
> function main() {
> 
>     *var* factory = *new* UserFactoryImpl();
> 
>     var user = factory.getUser(cocoon.request, userId);
> 
>            …
> 
> }
> 
>  
> 
> Thx in advance,
> 
> Robby
> 
>  
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
Biocenter Oulu and           | Fax: +358-8-553-1141
Department of Biochemistry   | Email: andre.juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat                   | WWW: www.strubiocat.oulu.fi
NordProt                     | WWW: www.nordprot.org
Triacle Biocomputing         | WWW: www.triacle-bc.com

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