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 Bon <bo...@unipattern.com> on 2008/07/31 11:59:44 UTC

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

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


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