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 Glen Mazza <gl...@gmail.com> on 2009/08/01 00:41:35 UTC

Re: Reliance on session.setAttribute() for error messages?


Woonsan Ko wrote:
> 
> I think it's not thread-safe but reliable for multiple users. A portlet
> session is based on the underlying servlet session which is unique per
> "user". So, it's reliable because other user cannot see the session
> attributes. However, if a user makes multiple requests and the requests
> trigger multiple threads, then multiple threads for the user can see the
> same session attribute.
> Anyway, I think it's reliable to store error information into session in
> your case.
> By the way, according to portlet api javadoc for PortletSession interface,
> it says:
> 
> "All objects stored in the session using the APPLICATION_SCOPE must be
> available to all the portlets, servlets and JSPs that belongs to the same
> portlet application and that handles a request identified as being a part
> of the same session. Objects stored in the session using the PORTLET_SCOPE
> must be available to the portlet during requests for the same portlet
> window that the objects where stored from. Attributes stored in the
> PORTLET_SCOPE are not protected from other web components of the portlet
> application. They are just conveniently namespaced."
> 
> Therefore, I think you can use PORTLET_SCOPE instead of APPLICATION_SCOPE
> to avoid the session attribute conflicts among portlet windows.
> 

Thanks Woonsan for the information.  I appreciate the help you've provided
me so far for both Pluto and Jetspeed.  I tried to switch to
PortletSession.PORTLET_SCOPE for both the ZIP Code data and the error
message but the JSP doesn't seem to work with it--I have to use
APPLICATION_SCOPE still.

Regards,
Glen

-- 
View this message in context: http://www.nabble.com/Reliance-on-session.setAttribute%28%29-for-error-messages--tp24750541p24764030.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: Reliance on session.setAttribute() for error messages?

Posted by Woonsan Ko <wo...@yahoo.com>.
Hi Glen,

--- On Sat, 8/1/09, Glen Mazza <gl...@gmail.com> wrote:

> From: Glen Mazza <gl...@gmail.com>
> Subject: Re: Reliance on session.setAttribute() for error messages?
> To: jetspeed-user@portals.apache.org
> Date: Saturday, August 1, 2009, 12:41 AM
> 
> 
> Woonsan Ko wrote:
> > 
> > I think it's not thread-safe but reliable for multiple
> users. A portlet
> > session is based on the underlying servlet session
> which is unique per
> > "user". So, it's reliable because other user cannot
> see the session
> > attributes. However, if a user makes multiple requests
> and the requests
> > trigger multiple threads, then multiple threads for
> the user can see the
> > same session attribute.
> > Anyway, I think it's reliable to store error
> information into session in
> > your case.
> > By the way, according to portlet api javadoc for
> PortletSession interface,
> > it says:
> > 
> > "All objects stored in the session using the
> APPLICATION_SCOPE must be
> > available to all the portlets, servlets and JSPs that
> belongs to the same
> > portlet application and that handles a request
> identified as being a part
> > of the same session. Objects stored in the session
> using the PORTLET_SCOPE
> > must be available to the portlet during requests for
> the same portlet
> > window that the objects where stored from. Attributes
> stored in the
> > PORTLET_SCOPE are not protected from other web
> components of the portlet
> > application. They are just conveniently namespaced."
> > 
> > Therefore, I think you can use PORTLET_SCOPE instead
> of APPLICATION_SCOPE
> > to avoid the session attribute conflicts among portlet
> windows.
> > 
> 
> Thanks Woonsan for the information.  I appreciate the
> help you've provided
> me so far for both Pluto and Jetspeed.  I tried to
> switch to
> PortletSession.PORTLET_SCOPE for both the ZIP Code data and
> the error
> message but the JSP doesn't seem to work with it--I have to
> use
> APPLICATION_SCOPE still.

If you want to stick to PORTLET_SCOPE, then you should get the portlet session, not servlet session.
The following line in your jsp page retrieves an attribute from the servlet session. (The JSTL tag will look up pageContext, request, session, application until the attribute is found.)

<c:set var="item" value="${ZipCodeData}" />

If you add the following line, you can access the renderRequest:

<portlet:defineObjects/>

(An example page: http://portals.apache.org/tutorials/jetspeed-2/04/taglib.html)

After the above tag, you can retrieve the attribute like this:

<%=renderRequest.getPortletSession().getAttribute("ZipCodeData") %>


Kind regards,

Woonsan

> 
> Regards,
> Glen
> 
> -- 
> View this message in context: http://www.nabble.com/Reliance-on-session.setAttribute%28%29-for-error-messages--tp24750541p24764030.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
> 
> 


      

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