tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Len Popp" <len.p...@gmail.com>
Subject Re: getSession() thread-safe? User A can see user B's account
Date Fri, 21 Jul 2006 14:45:52 GMT
On 7/21/06, Christopher Schultz <chris@christopherschultz.net> wrote:
> Dave,
>
> > I am using JSF (apache faces). The way to get Session or
> > HttpServletRequest from a backing bean is through FacesContext.
> > Backing beans are not servlet, so can not access HttpServletRequest
> > directly.
> >
> > After synchronizing the method, I still got the same problem.
>
> Synchronization is not the problem: the lack of any identifying piece of
> information is the problem. You have to have a way to identify which
> user you are working with in order to get the session.
>
> >     public static HttpSession getHttpSession(boolean create) {
> >     FacesContext context = FacesContext.getCurrentInstance();
> >     return (HttpSession)context.getExternalContext().getSession(create);
> >   }
>
> There is no information about the user, here. How does
> FacesContext.getSession know which session to get?!
>
> > It is in production stage and users are starting to use it. I am very
> > nervous.
>
> You certainly cannot think about going live with such a bad bug. What is
> the product?
>
> -chris
>

According to the JSF documentation, FacesContext.getCurrentInstance
and ExternalContext.getSession are supposed to return information
about the current request, i.e. "the request that is being processed
by the current thread". I haven't used JSF myself so I can't say if
there's a problem getting the session that way, but it looks correct
at first glance.

References:
http://java.sun.com/javaee/javaserverfaces/1.0/docs/api/javax/faces/context/FacesContext.html
http://java.sun.com/javaee/javaserverfaces/1.0/docs/api/javax/faces/context/ExternalContext.html
-- 
Len

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message