You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Oleg Konovalov <ol...@yahoo.com> on 2006/09/18 06:06:24 UTC

Getting Cocoon Session from outside

Hi,

I am trying to integrate Cocoon 2.04 application with the Java [SpringMVC] app.
Is there a way to obtain Cocoon Session [or ObjectModel] from outside of Cocoon application ?
I need session to get a UserProfile.

Please advise.
 
Thank you in advance,
Oleg.


Re: Getting Cocoon Session from outside

Posted by Oleg Konovalov <ol...@yahoo.com>.
> you could keep the display templates etc. in separate directories 
> but at the very least they have to share the WEB-INF.
That means I can not even place the whole Spring project inside of Cocoon one as a separate directory
because WEB-INF has to be right behing the root directory, correct ?

If I place  Spring project JSPs in a separate directory within Cocoon project, 
where/how do I map it (specify it that Spring PageController knows where they are)?
(as of now, they are in the root of Spring app)   
 
Thank you,
Oleg.

----- Original Message ----
From: Jason Johnston <co...@lojjic.net>
To: users@cocoon.apache.org
Sent: Thursday, September 21, 2006 8:59:32 AM
Subject: Re: Getting Cocoon Session from outside

Oleg Konovalov wrote:
> Jason,
> 
>  >It's all one "project", with a single web.xml file for the two servlets.
> So you are saying they have to be merged into one web application.
> Is there a way to keep them in 2 separate directories on the same level 
> (e.g. /deploy/app1  &  /deploy/app2)
> so I can build them separately with ant, keep them separately in CVS, etc ?
> I would like to avoid merging them completely...

Hmm, not that I know of.  I guess you could keep the display templates 
etc. in separate directories but at the very least they have to share 
the WEB-INF.  I guess that's the tradeoff: if you want two servlets to 
share session data then they have to be within the same application.

Anyone else have any ideas?

>  
> Thank you,
> Oleg.
> 
> 
> ----- Original Message ----
> From: Jason Johnston <co...@lojjic.net>
> To: users@cocoon.apache.org
> Sent: Wednesday, September 20, 2006 6:27:12 PM
> Subject: Re: Getting Cocoon Session from outside
> 
> Oleg Konovalov wrote:
>  > Jason,
>  >
>  > Is that two or one Web Project(s) ?
>  >
>  > Looking at the servlet-mapping's url-pattern:
>  >
>  > <servlet-mapping>
>  >    <servlet-name>SpringMVC</servlet-name>
>  >    <url-pattern>/spring/*</url-pattern>
>  > </servlet-mapping>
>  >
>  > <servlet-mapping>
>  >    <servlet-name>Cocoon</servlet-name>
>  >    <url-pattern>/*</url-pattern>
>  > </servlet-mapping>
>  >
>  > Looks like you put the SpringMVC project inside the Coocoon web project
>  > [<cocoon-app>/spring].
>  > Or can they still be 2 separate web projects (with root on the same
>  > level, like /cocoon-app &  /spring-app) ?
>  >
>  > But AFAIK each web project must have it's own /WEB-INF/web.xml. Is that
>  > not correct ?
> 
> 
> Both servlets are configured within the same servlet context, so they
> would result in URLs like:
> 
> http://localhost:8080/mycontext/spring/mySpringForm.form
> http://localhost:8080/mycontext/cocoon-transformed-document.xml
> 
> The mappings are just saying that any path within the servlet context
> that starts with /spring/ will use the Spring servlet, and anything else
> will use the Cocoon servlet.  It's all one "project", with a single
> web.xml file for the two servlets.
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Getting Cocoon Session from outside

Posted by Jason Johnston <co...@lojjic.net>.
Oleg Konovalov wrote:
> Jason,
> 
>  >It's all one "project", with a single web.xml file for the two servlets.
> So you are saying they have to be merged into one web application.
> Is there a way to keep them in 2 separate directories on the same level 
> (e.g. /deploy/app1  &  /deploy/app2)
> so I can build them separately with ant, keep them separately in CVS, etc ?
> I would like to avoid merging them completely...

Hmm, not that I know of.  I guess you could keep the display templates 
etc. in separate directories but at the very least they have to share 
the WEB-INF.  I guess that's the tradeoff: if you want two servlets to 
share session data then they have to be within the same application.

Anyone else have any ideas?

>  
> Thank you,
> Oleg.
> 
> 
> ----- Original Message ----
> From: Jason Johnston <co...@lojjic.net>
> To: users@cocoon.apache.org
> Sent: Wednesday, September 20, 2006 6:27:12 PM
> Subject: Re: Getting Cocoon Session from outside
> 
> Oleg Konovalov wrote:
>  > Jason,
>  >
>  > Is that two or one Web Project(s) ?
>  >
>  > Looking at the servlet-mapping's url-pattern:
>  >
>  > <servlet-mapping>
>  >    <servlet-name>SpringMVC</servlet-name>
>  >    <url-pattern>/spring/*</url-pattern>
>  > </servlet-mapping>
>  >
>  > <servlet-mapping>
>  >    <servlet-name>Cocoon</servlet-name>
>  >    <url-pattern>/*</url-pattern>
>  > </servlet-mapping>
>  >
>  > Looks like you put the SpringMVC project inside the Coocoon web project
>  > [<cocoon-app>/spring].
>  > Or can they still be 2 separate web projects (with root on the same
>  > level, like /cocoon-app &  /spring-app) ?
>  >
>  > But AFAIK each web project must have it's own /WEB-INF/web.xml. Is that
>  > not correct ?
> 
> 
> Both servlets are configured within the same servlet context, so they
> would result in URLs like:
> 
> http://localhost:8080/mycontext/spring/mySpringForm.form
> http://localhost:8080/mycontext/cocoon-transformed-document.xml
> 
> The mappings are just saying that any path within the servlet context
> that starts with /spring/ will use the Spring servlet, and anything else
> will use the Cocoon servlet.  It's all one "project", with a single
> web.xml file for the two servlets.
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Getting Cocoon Session from outside

Posted by Oleg Konovalov <ol...@yahoo.com>.
Jason,

>It's all one "project", with a single web.xml file for the two servlets.So you are saying they have to be merged into one web application.
Is there a way to keep them in 2 separate directories on the same level (e.g. /deploy/app1  &  /deploy/app2)
so I can build them separately with ant, keep them separately in CVS, etc ?
I would like to avoid merging them completely...
 
Thank you,
Oleg.

----- Original Message ----
From: Jason Johnston <co...@lojjic.net>
To: users@cocoon.apache.org
Sent: Wednesday, September 20, 2006 6:27:12 PM
Subject: Re: Getting Cocoon Session from outside

Oleg Konovalov wrote:
> Jason,
> 
> Is that two or one Web Project(s) ?
> 
> Looking at the servlet-mapping's url-pattern:
> 
> <servlet-mapping>
>    <servlet-name>SpringMVC</servlet-name>
>    <url-pattern>/spring/*</url-pattern>
> </servlet-mapping>
> 
> <servlet-mapping>
>    <servlet-name>Cocoon</servlet-name>
>    <url-pattern>/*</url-pattern>
> </servlet-mapping>
> 
> Looks like you put the SpringMVC project inside the Coocoon web project 
> [<cocoon-app>/spring].
> Or can they still be 2 separate web projects (with root on the same 
> level, like /cocoon-app &  /spring-app) ?
> 
> But AFAIK each web project must have it's own /WEB-INF/web.xml. Is that 
> not correct ?


Both servlets are configured within the same servlet context, so they 
would result in URLs like:

http://localhost:8080/mycontext/spring/mySpringForm.form
http://localhost:8080/mycontext/cocoon-transformed-document.xml

The mappings are just saying that any path within the servlet context 
that starts with /spring/ will use the Spring servlet, and anything else 
will use the Cocoon servlet.  It's all one "project", with a single 
web.xml file for the two servlets.



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






Re: Getting Cocoon Session from outside

Posted by Jason Johnston <co...@lojjic.net>.
Oleg Konovalov wrote:
> Jason,
> 
> Is that two or one Web Project(s) ?
> 
> Looking at the servlet-mapping's url-pattern:
> 
> <servlet-mapping>
>    <servlet-name>SpringMVC</servlet-name>
>    <url-pattern>/spring/*</url-pattern>
> </servlet-mapping>
> 
> <servlet-mapping>
>    <servlet-name>Cocoon</servlet-name>
>    <url-pattern>/*</url-pattern>
> </servlet-mapping>
> 
> Looks like you put the SpringMVC project inside the Coocoon web project 
> [<cocoon-app>/spring].
> Or can they still be 2 separate web projects (with root on the same 
> level, like /cocoon-app &  /spring-app) ?
> 
> But AFAIK each web project must have it's own /WEB-INF/web.xml. Is that 
> not correct ?


Both servlets are configured within the same servlet context, so they 
would result in URLs like:

http://localhost:8080/mycontext/spring/mySpringForm.form
http://localhost:8080/mycontext/cocoon-transformed-document.xml

The mappings are just saying that any path within the servlet context 
that starts with /spring/ will use the Spring servlet, and anything else 
will use the Cocoon servlet.  It's all one "project", with a single 
web.xml file for the two servlets.



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


Re: Getting Cocoon Session from outside

Posted by Oleg Konovalov <ol...@yahoo.com>.
Jason,

Is that two or one Web Project(s) ?

Looking at the servlet-mapping's url-pattern: 

<servlet-mapping>
   <servlet-name>SpringMVC</servlet-name>
   <url-pattern>/spring/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>Cocoon</servlet-name>
   <url-pattern>/*</url-pattern>
</servlet-mapping>

Looks like you put the SpringMVC project inside the Coocoon web project [<cocoon-app>/spring].
Or can they still be 2 separate web projects (with root on the same level, like /cocoon-app &  /spring-app) ?

But AFAIK each web project must have it's own /WEB-INF/web.xml. Is that not correct ?
 
Thank you,
Oleg.

----- Original Message ----
From: Jason Johnston <co...@lojjic.net>
To: users@cocoon.apache.org
Sent: Monday, September 18, 2006 11:20:17 PM
Subject: Re: Getting Cocoon Session from outside

Oleg Konovalov wrote:
> Jason,
> 
> So you are saying that Java/SpringMVC app should become a part of Cocoon 
> app, right ?
> Otherwise how can they share web.xml...
> 
> Please explain in more details.

web.xml isn't specific to Cocoon, it's the way that Java servlets in 
general are configured.  You can configure multiple servlets within a 
single web.xml file.  The web.xml that ships with Cocoon just has the 
CocoonServlet configured within it, but you can easily add other 
servlets, such as the Spring MVC servlet, in the same file.  It doesn't 
"become a part of Cocoon", it lives alongside it.

> 
> Any code sample ?
> (I am a novice in both SpringMVC and Cocoon)

I've never used SpringMVC, but looking quickly at the docs it uses a 
DispatcherServlet.  So for instance in your web.xml you can configure 
everything under the path "spring/" to use the DispatcherServlet, and 
everything else to use CocoonServlet:

<servlet>
   <servlet-name>Cocoon</servlet-name>
   <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
   ...(the rest from Cocoon's default web.xml)...
</servlet>

<servlet>
   <servlet-name>SpringMVC</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
   ...(see Spring's documentation for other configuration)...
</servlet>

<servlet-mapping>
   <servlet-name>SpringMVC</servlet-name>
   <url-pattern>/spring/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>Cocoon</servlet-name>
   <url-pattern>/*</url-pattern>
</servlet-mapping>

So that's pretty much it.  Both servlets are now configured in the same 
servlet container and share a HTTPSession.

Hope that helps.



> 
> ----- Original Message ----
> From: Jason Johnston <co...@lojjic.net>
> To: users@cocoon.apache.org
> Sent: Monday, September 18, 2006 9:19:17 AM
> Subject: Re: Getting Cocoon Session from outside
> 
> Oleg Konovalov wrote:
>  > Hi,
>  >
>  > I am trying to integrate Cocoon 2.04 application with the Java
>  > [SpringMVC] app.
>  > Is there a way to obtain Cocoon Session [or ObjectModel] from outside of
>  > Cocoon application ?
>  > I need session to get a UserProfile.
> 
> If you configure the Spring MVC servlet within the same servlet context
> (the same web.xml) as Cocoon, then the two servlets have access to the
> same HTTPSession.  You'll just need to set up your servlet-mappings so
> that one pattern uses Spring's servlet and the other uses the Cocoon
> servlet.
> 
> ---------------------------------------------------------------------
> 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: Getting Cocoon Session from outside

Posted by Jason Johnston <co...@lojjic.net>.
Oleg Konovalov wrote:
> Jason,
> 
> So you are saying that Java/SpringMVC app should become a part of Cocoon 
> app, right ?
> Otherwise how can they share web.xml...
> 
> Please explain in more details.

web.xml isn't specific to Cocoon, it's the way that Java servlets in 
general are configured.  You can configure multiple servlets within a 
single web.xml file.  The web.xml that ships with Cocoon just has the 
CocoonServlet configured within it, but you can easily add other 
servlets, such as the Spring MVC servlet, in the same file.  It doesn't 
"become a part of Cocoon", it lives alongside it.

> 
> Any code sample ?
> (I am a novice in both SpringMVC and Cocoon)

I've never used SpringMVC, but looking quickly at the docs it uses a 
DispatcherServlet.  So for instance in your web.xml you can configure 
everything under the path "spring/" to use the DispatcherServlet, and 
everything else to use CocoonServlet:

<servlet>
   <servlet-name>Cocoon</servlet-name>
   <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
   ...(the rest from Cocoon's default web.xml)...
</servlet>

<servlet>
   <servlet-name>SpringMVC</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
   ...(see Spring's documentation for other configuration)...
</servlet>

<servlet-mapping>
   <servlet-name>SpringMVC</servlet-name>
   <url-pattern>/spring/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>Cocoon</servlet-name>
   <url-pattern>/*</url-pattern>
</servlet-mapping>

So that's pretty much it.  Both servlets are now configured in the same 
servlet container and share a HTTPSession.

Hope that helps.



> 
> ----- Original Message ----
> From: Jason Johnston <co...@lojjic.net>
> To: users@cocoon.apache.org
> Sent: Monday, September 18, 2006 9:19:17 AM
> Subject: Re: Getting Cocoon Session from outside
> 
> Oleg Konovalov wrote:
>  > Hi,
>  >
>  > I am trying to integrate Cocoon 2.04 application with the Java
>  > [SpringMVC] app.
>  > Is there a way to obtain Cocoon Session [or ObjectModel] from outside of
>  > Cocoon application ?
>  > I need session to get a UserProfile.
> 
> If you configure the Spring MVC servlet within the same servlet context
> (the same web.xml) as Cocoon, then the two servlets have access to the
> same HTTPSession.  You'll just need to set up your servlet-mappings so
> that one pattern uses Spring's servlet and the other uses the Cocoon
> servlet.
> 
> ---------------------------------------------------------------------
> 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: Getting Cocoon Session from outside

Posted by Oleg Konovalov <ol...@yahoo.com>.
Jason,

So you are saying that Java/SpringMVC app should become a part of Cocoon app, right ?
Otherwise how can they share web.xml...

Please explain in more details.

Any code sample ?
(I am a novice in both SpringMVC and Cocoon)

Any help is very appreciated.
 
Thank you,
Oleg.

----- Original Message ----
From: Jason Johnston <co...@lojjic.net>
To: users@cocoon.apache.org
Sent: Monday, September 18, 2006 9:19:17 AM
Subject: Re: Getting Cocoon Session from outside

Oleg Konovalov wrote:
> Hi,
> 
> I am trying to integrate Cocoon 2.04 application with the Java 
> [SpringMVC] app.
> Is there a way to obtain Cocoon Session [or ObjectModel] from outside of 
> Cocoon application ?
> I need session to get a UserProfile.

If you configure the Spring MVC servlet within the same servlet context 
(the same web.xml) as Cocoon, then the two servlets have access to the 
same HTTPSession.  You'll just need to set up your servlet-mappings so 
that one pattern uses Spring's servlet and the other uses the Cocoon 
servlet.

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






Re: Getting Cocoon Session from outside

Posted by Jason Johnston <co...@lojjic.net>.
Oleg Konovalov wrote:
> Hi,
> 
> I am trying to integrate Cocoon 2.04 application with the Java 
> [SpringMVC] app.
> Is there a way to obtain Cocoon Session [or ObjectModel] from outside of 
> Cocoon application ?
> I need session to get a UserProfile.

If you configure the Spring MVC servlet within the same servlet context 
(the same web.xml) as Cocoon, then the two servlets have access to the 
same HTTPSession.  You'll just need to set up your servlet-mappings so 
that one pattern uses Spring's servlet and the other uses the Cocoon 
servlet.

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