Hi Glen,
--- On Fri, 7/31/09, Glen Mazza <glen.ma...@gmail.com> wrote: > From: Glen Mazza <glen.ma...@gmail.com> > Subject: Reliance on session.setAttribute() for error messages? > To: jetspeed-user@portals.apache.org > Date: Friday, July 31, 2009, 5:34 AM > > Hello, > > I just wrote a blog entry on making SOAP client calls from > a Jetspeed-hosted > portlet[1] but am not sure about one point in my code--in > Step #4, I'm > relying on the following statement to send error messages > back to the view > (the JSP page) for display: > > session.setAttribute("ErrorString", "Nothing found for ZIP > Code: " + > zipCode, PortletSession.APPLICATION_SCOPE); > > Is that thread-safe and reliable for multiple users? 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. Regards, Woonsan > > Thanks, > Glen > > [1] http://www.jroller.com/gmazza/date/20090730 > > -- > View this message in context: > http://www.nabble.com/Reliance-on-session.setAttribute%28%29-for-error-messages--tp24750541p24750541.html > Sent from the Jetspeed - User mailing list archive at > Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: jetspeed-user-unsubscr...@portals.apache.org > For additional commands, e-mail: jetspeed-user-h...@portals.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-user-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-user-h...@portals.apache.org