myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksei Valikov <>
Subject Re: How does RedirectTrackerManager
Date Wed, 13 Sep 2006 15:52:28 GMT

> I've got a bit of problem here with JSF. Somehow, i get my backing bean
> linked to the session, while they should be request time only.
> Here is my situation
> engineBean (request scope) is created by JSF (coming from a <bean>
> section in config)
>  it returns an array of AssignmentBean, using various information from
> current user's account. Those bean are wrappers around a proprietary object
> then a jsp page has a datatable showing those AssignmentBean (using a
> value binding in form #{engineBean.assignments}) using HtmlOutput tags
> Questions:
> 1) How comes those beans, which are supposed to have a request scope
> only, end up stored in the session scope object
> "org.apache.myfaces.custom.redirectTracker.RedirectTrackerManager"
> 2) How to prevent this, considering those AssignmentBean are not
> serializable and will never be, and a such should never reach the
> session level.
> Thanks for information, currently this lead to bunch of exception when
> stopping tomcat because user sessions can not be serialized anymore!

The probem with request scope beans is that they get lost during the redirect. 
If you have a request scoped bean and get redirected (for instance if you invoke 
an action that navigates you to another page and it's redirect in navigation), 
you will actually get two requests. Consequently all the request beans 
instantiated on the first request will not appear in the second request. This 
may be a problem for many applications.

The solution is to track down redirects. Every time a redirect is executed, a 
special token is appended to the target URL. Then, upon receiving the second 
request, this token may be used to identify the redirect transition. This allows 
saving request beans in the session using the token before redirect and restore 
them for the request scope right after the redirect.

This allows request scope beans survive the redirect (and answers your first 

As for the second question. In order to avoid serialization problems you 
session-based storage of request beans should be transient. If it's not the case 
in MyFaces, then it's a bug. File it or try to correct it yourself.


View raw message