You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Brice Lambi <la...@gmail.com> on 2006/09/21 18:29:09 UTC

Share data between servlet and portlet using session

Hello,
	I would like to set a session variable in a servlet and retrieve it in
a portlet.  Both are in the same application, but it doesn't appear to
work.  I've set an attribute using the HttpSession in a servlet, but the
attribute is null when I try to get it using the PortletSession.  I've
tried it the other way also, setting a variable in a portlet and trying
to retrieve it in a servlet.  That also does not work.  Is there any way
to accomplish this?

Thanks,
Brice


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Share data between servlet and portlet using session

Posted by Brice Lambi <la...@gmail.com>.
Thanks, for your help.  I understand the scoping differences, even
passing application scope to the getAttribute method doesn't make a
difference.  Here is my scenario:

Set an attribute in a servlet using HttpSession.
Get the attribute in a portlet using PortletSession calling getAttribute
(I tried with and without scope parameter).  The value is null.  Use
getAttributeNames to get an enumeration of names (using application
scope) and the attribute I set in the servlet is not there.

Is this possible with jetspeed?

Thanks,
Brice

On Thu, 2006-09-21 at 18:41 +0200, Jacek Wiślicki wrote:
> Wiadomosc od Brice Lambi z 2006-09-21 18:29 brzmiala:
> 
> > 	I would like to set a session variable in a servlet and retrieve it in
> > a portlet.  Both are in the same application, but it doesn't appear to
> > work.  I've set an attribute using the HttpSession in a servlet, but the
> > attribute is null when I try to get it using the PortletSession.  I've
> > tried it the other way also, setting a variable in a portlet and trying
> > to retrieve it in a servlet.  That also does not work.  Is there any way
> > to accomplish this?
> Be sure you use PortletSession.APPLICATION_SCOPE, not 
> PortletSession.PORTLET_SCOPE (this is a default for the second method 
> argument).
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Share data between servlet and portlet using session

Posted by Aaron Evans <aa...@gmail.com>.
Yes, that is an excellent explanation.  Thanks John!

On 9/25/06, John Lewis <jl...@unicon.net> wrote:
> There is a detailed description of this issue in the Spring Portlet MVC FAQ:
>
> http://opensource.atlassian.com/confluence/spring/x/Oww
>
>
>
> Brice Lambi wrote:
> > I found the solution in the mailing list archives.  I needed to add
> > emptySessionPath="true" to the connector element in tomcat's server.xml
> > file.  So it looks like this:
> >
> >  <Connector port="8080" maxHttpHeaderSize="8192"
> >                maxThreads="150" minSpareThreads="25"
> > maxSpareThreads="75"
> >                enableLookups="false" redirectPort="8443"
> > acceptCount="100"
> >                connectionTimeout="20000" disableUploadTimeout="true"
> > emptySessionPath="true"/>
> >
> >
> > Thanks,
> > Brice
> >
> >
> > On Thu, 2006-09-21 at 18:41 +0200, Jacek Wiślicki wrote:
> >
> >> Wiadomosc od Brice Lambi z 2006-09-21 18:29 brzmiala:
> >>
> >>
> >>>     I would like to set a session variable in a servlet and retrieve it in
> >>> a portlet.  Both are in the same application, but it doesn't appear to
> >>> work.  I've set an attribute using the HttpSession in a servlet, but the
> >>> attribute is null when I try to get it using the PortletSession.  I've
> >>> tried it the other way also, setting a variable in a portlet and trying
> >>> to retrieve it in a servlet.  That also does not work.  Is there any way
> >>> to accomplish this?
> >>>
> >> Be sure you use PortletSession.APPLICATION_SCOPE, not
> >> PortletSession.PORTLET_SCOPE (this is a default for the second method
> >> argument).
> >>
> >>
>
>
>

Re: Share data between servlet and portlet using session

Posted by John Lewis <jl...@unicon.net>.
There is a detailed description of this issue in the Spring Portlet MVC FAQ:

http://opensource.atlassian.com/confluence/spring/x/Oww



Brice Lambi wrote:
> I found the solution in the mailing list archives.  I needed to add
> emptySessionPath="true" to the connector element in tomcat's server.xml
> file.  So it looks like this:
>
>  <Connector port="8080" maxHttpHeaderSize="8192"
>                maxThreads="150" minSpareThreads="25"
> maxSpareThreads="75"
>                enableLookups="false" redirectPort="8443"
> acceptCount="100"
>                connectionTimeout="20000" disableUploadTimeout="true"
> emptySessionPath="true"/>
>
>
> Thanks,
> Brice
>
>
> On Thu, 2006-09-21 at 18:41 +0200, Jacek Wiślicki wrote:
>   
>> Wiadomosc od Brice Lambi z 2006-09-21 18:29 brzmiala:
>>
>>     
>>> 	I would like to set a session variable in a servlet and retrieve it in
>>> a portlet.  Both are in the same application, but it doesn't appear to
>>> work.  I've set an attribute using the HttpSession in a servlet, but the
>>> attribute is null when I try to get it using the PortletSession.  I've
>>> tried it the other way also, setting a variable in a portlet and trying
>>> to retrieve it in a servlet.  That also does not work.  Is there any way
>>> to accomplish this?
>>>       
>> Be sure you use PortletSession.APPLICATION_SCOPE, not 
>> PortletSession.PORTLET_SCOPE (this is a default for the second method 
>> argument).
>>
>>     

Re: Share data between servlet and portlet using session

Posted by Brice Lambi <la...@gmail.com>.
I found the solution in the mailing list archives.  I needed to add
emptySessionPath="true" to the connector element in tomcat's server.xml
file.  So it looks like this:

 <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
               enableLookups="false" redirectPort="8443"
acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"
emptySessionPath="true"/>


Thanks,
Brice


On Thu, 2006-09-21 at 18:41 +0200, Jacek Wiślicki wrote:
> Wiadomosc od Brice Lambi z 2006-09-21 18:29 brzmiala:
> 
> > 	I would like to set a session variable in a servlet and retrieve it in
> > a portlet.  Both are in the same application, but it doesn't appear to
> > work.  I've set an attribute using the HttpSession in a servlet, but the
> > attribute is null when I try to get it using the PortletSession.  I've
> > tried it the other way also, setting a variable in a portlet and trying
> > to retrieve it in a servlet.  That also does not work.  Is there any way
> > to accomplish this?
> Be sure you use PortletSession.APPLICATION_SCOPE, not 
> PortletSession.PORTLET_SCOPE (this is a default for the second method 
> argument).
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Share data between servlet and portlet using session

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Brice Lambi z 2006-09-21 18:29 brzmiala:

> 	I would like to set a session variable in a servlet and retrieve it in
> a portlet.  Both are in the same application, but it doesn't appear to
> work.  I've set an attribute using the HttpSession in a servlet, but the
> attribute is null when I try to get it using the PortletSession.  I've
> tried it the other way also, setting a variable in a portlet and trying
> to retrieve it in a servlet.  That also does not work.  Is there any way
> to accomplish this?
Be sure you use PortletSession.APPLICATION_SCOPE, not 
PortletSession.PORTLET_SCOPE (this is a default for the second method 
argument).

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


RE: Share data between servlet and portlet using session

Posted by "Boyce, Keith Garry" <Ke...@bcbsma.com>.
getPortletSession().getAttribute("xxx",PortletSession.APPLICATION_SCOPE)


-----Original Message-----
From: Brice Lambi [mailto:lambi.brice@gmail.com]
Sent: Thursday, September 21, 2006 12:29 PM
To: Jetspeed Users List
Subject: Share data between servlet and portlet using session

Hello,
	I would like to set a session variable in a servlet and retrieve
it in a portlet.  Both are in the same application, but it doesn't
appear to work.  I've set an attribute using the HttpSession in a
servlet, but the attribute is null when I try to get it using the
PortletSession.  I've tried it the other way also, setting a variable in
a portlet and trying to retrieve it in a servlet.  That also does not
work.  Is there any way to accomplish this?

Thanks,
Brice


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org

This message is a PRIVATE communication.
If you are not the intended recipient, please do not read, copy,
or use it, and do not disclose it to others. Please notify the
sender of the delivery error by replying to this message, and then
delete it from your system. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org