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 Ethan Adams <et...@gmail.com> on 2006/03/09 02:41:02 UTC

Re: [J2] Passing attributes from a portlet to a servlet...

I've seen many posts related to this, but no solutions that work for
me.  My understanding is that the HttpSession backing of
PortletSession is the portal application context session, not the
HttpSession for the portlet context.  Therefore, when the portlet
applications servlet tries to get the session value, it can't.

I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
say it is a pluto/Tomcat issue, and say setting crossContext="true"
and emptySessionPath="true" will solve the problem.  This didn't work
for me either.

I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?


> hello
>
> Andrew Hill a écrit :
>
> > Firstly you need to explicitly state that its Session Application Scope:
> >
> > PortletSession.setAttribute("listImage", m,
> > PortletSession.APPLICATION_SCOPE);
>
> i've just tried this, and it didn't work...
>
> >
> > Secondly check that your actually getting the same session in your
> > servlet. If you dont see anything in the attributes it would indicate
> > that its probably a different session, as even the PORTLET_SCOPE
> > attributes would show up with some namespacing applied.
>
> i don't really understand what you mean...
>
> >
> > How are you 'calling' the servlet? Is it in the same webapp?
>
> actually, my servlet is in the same webapp, and is generating a png
> image, so it's called by an <img> markup written in my portlet...
>
>
> Luc
>
> --
> Luc FOUIN - Stagiaire Aptiwan
> 14 rue Niepce
> 75014 Paris
> Tél : 06 77 95 17 24
> Mél : luc.fouin@aptiwan.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>

Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Ethan Adams <et...@gmail.com>.
I think I found the problem.  It works when accessing the Portal over
8080, but when going through Apache and the AJP connector, it doesn't.
 Any ideas on how to solve that?

On 3/8/06, Ethan Adams <et...@gmail.com> wrote:
> 1. I have  emptySessionPath="true" set for the AJP connector and the
> 8080 connector.  I'm using AJP with an Apache 2 connector.
> 2. I have the default setting of crossContext="true" in the
> Catalina/localhost/jetspeed.xml file
> 3. I hit a portal page with the portlet on it.
> 4. The portlet calls a JSP with this code:
>    <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
> PortletSession.APPLICATION_SCOPE);%>
> 5.  Then call a JSP that contains the following directly, and get null.
>    <%=request.getSession().getAttribute("test")%>
>
> Any thoughts?
>
> On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> > Ethan,
> >
> > Yes... it does work... at least with JJ svn HEAD:
> >
> > 1. Make sure the portlet is hit first, (e.g. before the servlet in the
> > browser session).
> > 2. You must use APPLICATION_SCOPE portlet attributes.
> > 3. emptySessionPath="true" must be set on the Tomcat connector in use.
> > 4. Tomcat 5.5.4+ is required.
> > 5. crossContext="true" must be set for the jetspeed webapp... which it
> > is by default.
> >
> > HTH,
> >
> > Randy
> >
> > Ethan Adams wrote:
> > > I've seen many posts related to this, but no solutions that work for
> > > me.  My understanding is that the HttpSession backing of
> > > PortletSession is the portal application context session, not the
> > > HttpSession for the portlet context.  Therefore, when the portlet
> > > applications servlet tries to get the session value, it can't.
> > >
> > > I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
> > > say it is a pluto/Tomcat issue, and say setting crossContext="true"
> > > and emptySessionPath="true" will solve the problem.  This didn't work
> > > for me either.
> > >
> > > I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?
> > >
> > >
> > >
> > >> hello
> > >>
> > >> Andrew Hill a écrit :
> > >>
> > >>
> > >>> Firstly you need to explicitly state that its Session Application Scope:
> > >>>
> > >>> PortletSession.setAttribute("listImage", m,
> > >>> PortletSession.APPLICATION_SCOPE);
> > >>>
> > >> i've just tried this, and it didn't work...
> > >>
> > >>
> > >>> Secondly check that your actually getting the same session in your
> > >>> servlet. If you dont see anything in the attributes it would indicate
> > >>> that its probably a different session, as even the PORTLET_SCOPE
> > >>> attributes would show up with some namespacing applied.
> > >>>
> > >> i don't really understand what you mean...
> > >>
> > >>
> > >>> How are you 'calling' the servlet? Is it in the same webapp?
> > >>>
> > >> actually, my servlet is in the same webapp, and is generating a png
> > >> image, so it's called by an <img> markup written in my portlet...
> > >>
> > >>
> > >> Luc
> > >>
> > >> --
> > >> Luc FOUIN - Stagiaire Aptiwan
> > >> 14 rue Niepce
> > >> 75014 Paris
> > >> Tél : 06 77 95 17 24
> > >> Mél : luc.fouin@aptiwan.com
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> > >> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> > >>
> > >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >
> >
>

Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Aaron Evans <aa...@gmail.com>.
This is great!  I always thought that this didn't work because I thought the
session objects were  being kept under jetspeed's context.  But all along it
was because I didn't have this AJP setting turned on.  I guess you learn
something everyday.

This is going to help me immensely.  Thanks for asking the question Ethan!


On 3/8/06, Ethan Adams <et...@gmail.com> wrote:
>
> Hold off on that.  My mistake.  My original problem WAS that I didn't
> have the emptySessionPath="true" setting on the AJP connector.  I only
> had it on the 8080 connector.
>
> I made the change, restarted, and tested and it appeared NOT to work.
> But now it seems to work.  I don't really know what happened there,
> but I seem to be all set now.
>
> Thanks for the help.
>
> On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> > Ethan,
> >
> > The difference in the situations where I have seen this work and yours
> > is that here you are dispatching across the webapp boundary. I have
> > always hit both the portlet and servlet from the browser. I am surprised
> > that this does not work straight out since the portlet and servlet are
> > both being invoked from the same context.
> >
> > One of the other J2 developers may have more insight. I'll ping them...
> >
> > Randy
> >
> > Ethan Adams wrote:
> > > 1. I have  emptySessionPath="true" set for the AJP connector and the
> > > 8080 connector.  I'm using AJP with an Apache 2 connector.
> > > 2. I have the default setting of crossContext="true" in the
> > > Catalina/localhost/jetspeed.xml file
> > > 3. I hit a portal page with the portlet on it.
> > > 4. The portlet calls a JSP with this code:
> > >     <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
> > > PortletSession.APPLICATION_SCOPE);%>
> > > 5.  Then call a JSP that contains the following directly, and get
> null.
> > >     <%=request.getSession().getAttribute("test")%>
> > >
> > > Any thoughts?
> > >
> > > On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> > >
> > >> Ethan,
> > >>
> > >> Yes... it does work... at least with JJ svn HEAD:
> > >>
> > >> 1. Make sure the portlet is hit first, (e.g. before the servlet in
> the
> > >> browser session).
> > >> 2. You must use APPLICATION_SCOPE portlet attributes.
> > >> 3. emptySessionPath="true" must be set on the Tomcat connector in
> use.
> > >> 4. Tomcat 5.5.4+ is required.
> > >> 5. crossContext="true" must be set for the jetspeed webapp... which
> it
> > >> is by default.
> > >>
> > >> HTH,
> > >>
> > >> Randy
> > >>
> > >> Ethan Adams wrote:
> > >>
> > >>> I've seen many posts related to this, but no solutions that work for
> > >>> me.  My understanding is that the HttpSession backing of
> > >>> PortletSession is the portal application context session, not the
> > >>> HttpSession for the portlet context.  Therefore, when the portlet
> > >>> applications servlet tries to get the session value, it can't.
> > >>>
> > >>> I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
> > >>> say it is a pluto/Tomcat issue, and say setting crossContext="true"
> > >>> and emptySessionPath="true" will solve the problem.  This didn't
> work
> > >>> for me either.
> > >>>
> > >>> I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this
> problem?
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>> hello
> > >>>>
> > >>>> Andrew Hill a écrit :
> > >>>>
> > >>>>
> > >>>>
> > >>>>> Firstly you need to explicitly state that its Session Application
> Scope:
> > >>>>>
> > >>>>> PortletSession.setAttribute("listImage", m,
> > >>>>> PortletSession.APPLICATION_SCOPE);
> > >>>>>
> > >>>>>
> > >>>> i've just tried this, and it didn't work...
> > >>>>
> > >>>>
> > >>>>
> > >>>>> Secondly check that your actually getting the same session in your
> > >>>>> servlet. If you dont see anything in the attributes it would
> indicate
> > >>>>> that its probably a different session, as even the PORTLET_SCOPE
> > >>>>> attributes would show up with some namespacing applied.
> > >>>>>
> > >>>>>
> > >>>> i don't really understand what you mean...
> > >>>>
> > >>>>
> > >>>>
> > >>>>> How are you 'calling' the servlet? Is it in the same webapp?
> > >>>>>
> > >>>>>
> > >>>> actually, my servlet is in the same webapp, and is generating a png
> > >>>> image, so it's called by an <img> markup written in my portlet...
> > >>>>
> > >>>>
> > >>>> Luc
> > >>>>
> > >>>> --
> > >>>> Luc FOUIN - Stagiaire Aptiwan
> > >>>> 14 rue Niepce
> > >>>> 75014 Paris
> > >>>> Tél : 06 77 95 17 24
> > >>>> Mél : luc.fouin@aptiwan.com
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail:
> jetspeed-user-unsubscribe@jakarta.apache.org
> > >>>> For additional commands, e-mail:
> jetspeed-user-help@jakarta.apache.org
> > >>>>
> > >>>>
> > >>>>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > >> For additional commands, e-mail:
> jetspeed-user-help@portals.apache.org
> > >>
> > >>
> > >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >
> >
>

Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Ethan Adams <et...@gmail.com>.
Hold off on that.  My mistake.  My original problem WAS that I didn't
have the emptySessionPath="true" setting on the AJP connector.  I only
had it on the 8080 connector.

I made the change, restarted, and tested and it appeared NOT to work. 
But now it seems to work.  I don't really know what happened there,
but I seem to be all set now.

Thanks for the help.

On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> Ethan,
>
> The difference in the situations where I have seen this work and yours
> is that here you are dispatching across the webapp boundary. I have
> always hit both the portlet and servlet from the browser. I am surprised
> that this does not work straight out since the portlet and servlet are
> both being invoked from the same context.
>
> One of the other J2 developers may have more insight. I'll ping them...
>
> Randy
>
> Ethan Adams wrote:
> > 1. I have  emptySessionPath="true" set for the AJP connector and the
> > 8080 connector.  I'm using AJP with an Apache 2 connector.
> > 2. I have the default setting of crossContext="true" in the
> > Catalina/localhost/jetspeed.xml file
> > 3. I hit a portal page with the portlet on it.
> > 4. The portlet calls a JSP with this code:
> >     <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
> > PortletSession.APPLICATION_SCOPE);%>
> > 5.  Then call a JSP that contains the following directly, and get null.
> >     <%=request.getSession().getAttribute("test")%>
> >
> > Any thoughts?
> >
> > On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> >
> >> Ethan,
> >>
> >> Yes... it does work... at least with JJ svn HEAD:
> >>
> >> 1. Make sure the portlet is hit first, (e.g. before the servlet in the
> >> browser session).
> >> 2. You must use APPLICATION_SCOPE portlet attributes.
> >> 3. emptySessionPath="true" must be set on the Tomcat connector in use.
> >> 4. Tomcat 5.5.4+ is required.
> >> 5. crossContext="true" must be set for the jetspeed webapp... which it
> >> is by default.
> >>
> >> HTH,
> >>
> >> Randy
> >>
> >> Ethan Adams wrote:
> >>
> >>> I've seen many posts related to this, but no solutions that work for
> >>> me.  My understanding is that the HttpSession backing of
> >>> PortletSession is the portal application context session, not the
> >>> HttpSession for the portlet context.  Therefore, when the portlet
> >>> applications servlet tries to get the session value, it can't.
> >>>
> >>> I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
> >>> say it is a pluto/Tomcat issue, and say setting crossContext="true"
> >>> and emptySessionPath="true" will solve the problem.  This didn't work
> >>> for me either.
> >>>
> >>> I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?
> >>>
> >>>
> >>>
> >>>
> >>>> hello
> >>>>
> >>>> Andrew Hill a écrit :
> >>>>
> >>>>
> >>>>
> >>>>> Firstly you need to explicitly state that its Session Application Scope:
> >>>>>
> >>>>> PortletSession.setAttribute("listImage", m,
> >>>>> PortletSession.APPLICATION_SCOPE);
> >>>>>
> >>>>>
> >>>> i've just tried this, and it didn't work...
> >>>>
> >>>>
> >>>>
> >>>>> Secondly check that your actually getting the same session in your
> >>>>> servlet. If you dont see anything in the attributes it would indicate
> >>>>> that its probably a different session, as even the PORTLET_SCOPE
> >>>>> attributes would show up with some namespacing applied.
> >>>>>
> >>>>>
> >>>> i don't really understand what you mean...
> >>>>
> >>>>
> >>>>
> >>>>> How are you 'calling' the servlet? Is it in the same webapp?
> >>>>>
> >>>>>
> >>>> actually, my servlet is in the same webapp, and is generating a png
> >>>> image, so it's called by an <img> markup written in my portlet...
> >>>>
> >>>>
> >>>> Luc
> >>>>
> >>>> --
> >>>> Luc FOUIN - Stagiaire Aptiwan
> >>>> 14 rue Niepce
> >>>> 75014 Paris
> >>>> Tél : 06 77 95 17 24
> >>>> Mél : luc.fouin@aptiwan.com
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> >>>> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> >>>>
> >>>>
> >>>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> >> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Randy Watler <wa...@wispertel.net>.
Ethan,

The difference in the situations where I have seen this work and yours 
is that here you are dispatching across the webapp boundary. I have 
always hit both the portlet and servlet from the browser. I am surprised 
that this does not work straight out since the portlet and servlet are 
both being invoked from the same context.

One of the other J2 developers may have more insight. I'll ping them...

Randy

Ethan Adams wrote:
> 1. I have  emptySessionPath="true" set for the AJP connector and the
> 8080 connector.  I'm using AJP with an Apache 2 connector.
> 2. I have the default setting of crossContext="true" in the
> Catalina/localhost/jetspeed.xml file
> 3. I hit a portal page with the portlet on it.
> 4. The portlet calls a JSP with this code:
>     <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
> PortletSession.APPLICATION_SCOPE);%>
> 5.  Then call a JSP that contains the following directly, and get null.
>     <%=request.getSession().getAttribute("test")%>
>
> Any thoughts?
>
> On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
>   
>> Ethan,
>>
>> Yes... it does work... at least with JJ svn HEAD:
>>
>> 1. Make sure the portlet is hit first, (e.g. before the servlet in the
>> browser session).
>> 2. You must use APPLICATION_SCOPE portlet attributes.
>> 3. emptySessionPath="true" must be set on the Tomcat connector in use.
>> 4. Tomcat 5.5.4+ is required.
>> 5. crossContext="true" must be set for the jetspeed webapp... which it
>> is by default.
>>
>> HTH,
>>
>> Randy
>>
>> Ethan Adams wrote:
>>     
>>> I've seen many posts related to this, but no solutions that work for
>>> me.  My understanding is that the HttpSession backing of
>>> PortletSession is the portal application context session, not the
>>> HttpSession for the portlet context.  Therefore, when the portlet
>>> applications servlet tries to get the session value, it can't.
>>>
>>> I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
>>> say it is a pluto/Tomcat issue, and say setting crossContext="true"
>>> and emptySessionPath="true" will solve the problem.  This didn't work
>>> for me either.
>>>
>>> I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?
>>>
>>>
>>>
>>>       
>>>> hello
>>>>
>>>> Andrew Hill a écrit :
>>>>
>>>>
>>>>         
>>>>> Firstly you need to explicitly state that its Session Application Scope:
>>>>>
>>>>> PortletSession.setAttribute("listImage", m,
>>>>> PortletSession.APPLICATION_SCOPE);
>>>>>
>>>>>           
>>>> i've just tried this, and it didn't work...
>>>>
>>>>
>>>>         
>>>>> Secondly check that your actually getting the same session in your
>>>>> servlet. If you dont see anything in the attributes it would indicate
>>>>> that its probably a different session, as even the PORTLET_SCOPE
>>>>> attributes would show up with some namespacing applied.
>>>>>
>>>>>           
>>>> i don't really understand what you mean...
>>>>
>>>>
>>>>         
>>>>> How are you 'calling' the servlet? Is it in the same webapp?
>>>>>
>>>>>           
>>>> actually, my servlet is in the same webapp, and is generating a png
>>>> image, so it's called by an <img> markup written in my portlet...
>>>>
>>>>
>>>> Luc
>>>>
>>>> --
>>>> Luc FOUIN - Stagiaire Aptiwan
>>>> 14 rue Niepce
>>>> 75014 Paris
>>>> Tél : 06 77 95 17 24
>>>> Mél : luc.fouin@aptiwan.com
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>>>>
>>>>
>>>>         
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
>> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>>
>>
>>     


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


Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Ethan Adams <et...@gmail.com>.
1. I have  emptySessionPath="true" set for the AJP connector and the
8080 connector.  I'm using AJP with an Apache 2 connector.
2. I have the default setting of crossContext="true" in the
Catalina/localhost/jetspeed.xml file
3. I hit a portal page with the portlet on it.
4. The portlet calls a JSP with this code:
    <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
PortletSession.APPLICATION_SCOPE);%>
5.  Then call a JSP that contains the following directly, and get null.
    <%=request.getSession().getAttribute("test")%>

Any thoughts?

On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
> Ethan,
>
> Yes... it does work... at least with JJ svn HEAD:
>
> 1. Make sure the portlet is hit first, (e.g. before the servlet in the
> browser session).
> 2. You must use APPLICATION_SCOPE portlet attributes.
> 3. emptySessionPath="true" must be set on the Tomcat connector in use.
> 4. Tomcat 5.5.4+ is required.
> 5. crossContext="true" must be set for the jetspeed webapp... which it
> is by default.
>
> HTH,
>
> Randy
>
> Ethan Adams wrote:
> > I've seen many posts related to this, but no solutions that work for
> > me.  My understanding is that the HttpSession backing of
> > PortletSession is the portal application context session, not the
> > HttpSession for the portlet context.  Therefore, when the portlet
> > applications servlet tries to get the session value, it can't.
> >
> > I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
> > say it is a pluto/Tomcat issue, and say setting crossContext="true"
> > and emptySessionPath="true" will solve the problem.  This didn't work
> > for me either.
> >
> > I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?
> >
> >
> >
> >> hello
> >>
> >> Andrew Hill a écrit :
> >>
> >>
> >>> Firstly you need to explicitly state that its Session Application Scope:
> >>>
> >>> PortletSession.setAttribute("listImage", m,
> >>> PortletSession.APPLICATION_SCOPE);
> >>>
> >> i've just tried this, and it didn't work...
> >>
> >>
> >>> Secondly check that your actually getting the same session in your
> >>> servlet. If you dont see anything in the attributes it would indicate
> >>> that its probably a different session, as even the PORTLET_SCOPE
> >>> attributes would show up with some namespacing applied.
> >>>
> >> i don't really understand what you mean...
> >>
> >>
> >>> How are you 'calling' the servlet? Is it in the same webapp?
> >>>
> >> actually, my servlet is in the same webapp, and is generating a png
> >> image, so it's called by an <img> markup written in my portlet...
> >>
> >>
> >> Luc
> >>
> >> --
> >> Luc FOUIN - Stagiaire Aptiwan
> >> 14 rue Niepce
> >> 75014 Paris
> >> Tél : 06 77 95 17 24
> >> Mél : luc.fouin@aptiwan.com
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: [J2] Passing attributes from a portlet to a servlet...

Posted by Randy Watler <wa...@wispertel.net>.
Ethan,

Yes... it does work... at least with JJ svn HEAD:

1. Make sure the portlet is hit first, (e.g. before the servlet in the 
browser session).
2. You must use APPLICATION_SCOPE portlet attributes.
3. emptySessionPath="true" must be set on the Tomcat connector in use.
4. Tomcat 5.5.4+ is required.
5. crossContext="true" must be set for the jetspeed webapp... which it 
is by default.

HTH,

Randy

Ethan Adams wrote:
> I've seen many posts related to this, but no solutions that work for
> me.  My understanding is that the HttpSession backing of
> PortletSession is the portal application context session, not the
> HttpSession for the portlet context.  Therefore, when the portlet
> applications servlet tries to get the session value, it can't.
>
> I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
> say it is a pluto/Tomcat issue, and say setting crossContext="true"
> and emptySessionPath="true" will solve the problem.  This didn't work
> for me either.
>
> I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this problem?
>
>
>   
>> hello
>>
>> Andrew Hill a écrit :
>>
>>     
>>> Firstly you need to explicitly state that its Session Application Scope:
>>>
>>> PortletSession.setAttribute("listImage", m,
>>> PortletSession.APPLICATION_SCOPE);
>>>       
>> i've just tried this, and it didn't work...
>>
>>     
>>> Secondly check that your actually getting the same session in your
>>> servlet. If you dont see anything in the attributes it would indicate
>>> that its probably a different session, as even the PORTLET_SCOPE
>>> attributes would show up with some namespacing applied.
>>>       
>> i don't really understand what you mean...
>>
>>     
>>> How are you 'calling' the servlet? Is it in the same webapp?
>>>       
>> actually, my servlet is in the same webapp, and is generating a png
>> image, so it's called by an <img> markup written in my portlet...
>>
>>
>> Luc
>>
>> --
>> Luc FOUIN - Stagiaire Aptiwan
>> 14 rue Niepce
>> 75014 Paris
>> Tél : 06 77 95 17 24
>> Mél : luc.fouin@aptiwan.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>>
>>     


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


Re: [J2] Passing attributes from a portlet to a servlet...

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Jul 31, 2008, at 2:59 AM, Bon wrote:

>
> Hi all,
>
>    There is a problem in my program, does it the same topic about this
> article?
>    My J2 is version 2.1.3 and tomcat is 5.5.23.
>    The following is the detail of my question:
>    When user login into my Portal, I've set some attributes in  
> HttpSession
>    at LoginRedirectorServlet, and I hope those attributes could be  
> access
>    in my portlets in my portlet-application.

You are setting attributes in the Jetspeed application's session,  
which is different from your portlet application's session. The  
servlet spec requires that these attributes are not shared between  
applications.
What you can try to do is set a request attribute on the jetspeed  
request (servlet) in your login redirector servlet, and then grab the  
attribute in your portlet with something like:

  Object attribute = null;
   Enumeration attributes = renderRequest.getAttributeNames();
   while (attributes.hasMoreElements())
   {
     String name = (String)attributes.nextElement();
     attribute = renderRequest.getAttribute(name);
     if (attribute!=null)
     {
       out.print(name + " = " + attribute + "<br/>");
     }
   }

You may need to set the request attribute in jetspeed after the  
redirect, preferably in a valve



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


RE: [J2] Passing attributes from a portlet to a servlet...

Posted by Bon <bo...@unipattern.com>.
Hi all,

    There is a problem in my program, does it the same topic about this
article?
    My J2 is version 2.1.3 and tomcat is 5.5.23.
    The following is the detail of my question:
    When user login into my Portal, I've set some attributes in HttpSession 
    at LoginRedirectorServlet, and I hope those attributes could be access
    in my portlets in my portlet-application.

    now, my portlets can not get those attributes in Portlet or JSP,
    in my Portlet doView method, my code like that
    String my_attribute = (String) renderRequest.getPortletSession().
                                     getAttribute("my-attribute",
PortletSession.APPLICATION_SCOPE);

    in my JSP, the code like that
    <%@ taglib uri='/WEB-INF/tld/portlet.tld' prefix='portlet' %>
    <portlet:defineObjects/>
    <%
    Enumeration psans = renderRequest.getPortletSession()
                                    
.getAttributeNames(PortletSession.APPLICATION_SCOPE);
    while(psans.hasMoreElements()){
        String psan = (String) psans.nextElement();
        out.print("\n " + psan + "=" + renderRequest.getPortletSession()
                               .getAttribute(psan,
PortletSession.APPLICATION_SCOPE));
	}
    %>
    
    I've set the emptySessionPath="true" in my tomcat sever.xml like that
        <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" 
               emptySessionPath="true" />
    but I still can not get the session attributes in my Portlets,
    does it the same thing about this article?

    and what should I do to fix my porblem?

Regards,
Bon


Boyce, Keith Garry wrote:
> 
> 
> If it's a jsp in portlet context then use <portlet:defineObjects tag.
> 
> -----Original Message-----
> From: Ethan Adams [mailto:ethanjadams@gmail.com]
> 
> Sent: Wednesday, March 08, 2006 9:26 PM
> To: Jetspeed Users List
> Subject: Re: [J2] Passing attributes from a portlet to a servlet...
> 
> 1. I have  emptySessionPath="true" set for the AJP connector and the 8080
> connector.  I'm using AJP with an Apache 2 connector.
> 2. I have the default setting of crossContext="true" in the
> Catalina/localhost/jetspeed.xml file 3. I hit a portal page with the
> portlet on it.
> 4. The portlet calls a JSP with this code:
>     <%renderRequest.getPortletSession().setAttribute("test", "MYTEST",
> PortletSession.APPLICATION_SCOPE);%>
> 5.  Then call a JSP that contains the following directly, and get null.
>     <%=request.getSession().getAttribute("test")%>
> 
> Any thoughts?
> 
> On 3/8/06, Randy Watler <wa...@wispertel.net> wrote:
>> Ethan,
>>
>> Yes... it does work... at least with JJ svn HEAD:
>>
>> 1. Make sure the portlet is hit first, (e.g. before the servlet in the
>> browser session).
>> 2. You must use APPLICATION_SCOPE portlet attributes.
>> 3. emptySessionPath="true" must be set on the Tomcat connector in use.
>> 4. Tomcat 5.5.4+ is required.
>> 5. crossContext="true" must be set for the jetspeed webapp... which it
>> is by default.
>> HTH,
>> Randy
>> Ethan Adams wrote:
>> > I've seen many posts related to this, but no solutions that work for
>> > me.  My understanding is that the HttpSession backing of
>> > PortletSession is the portal application context session, not the
>> > HttpSession for the portlet context.  Therefore, when the portlet
>> > applications servlet tries to get the session value, it can't.
>> > I've seen posts (http://issues.apache.org/jira/browse/PLUTO-53) that
>> > say it is a pluto/Tomcat issue, and say setting crossContext="true"
>> > and emptySessionPath="true" will solve the problem.  This didn't
>> > work for me either.
>> > I'm running Jetspeed 2.0 FINAL on Tomcat 5.5.12.  Anyone solve this
>> problem?
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 

-- 
View this message in context: http://www.nabble.com/Re%3A--J2--Passing-attributes-from-a-portlet-to-a-servlet...-tp3312840p18751274.html
Sent from the Jetspeed - User mailing list archive at Nabble.com.


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