At this stage, it is probably safe to say that a new CDI scope will be introduced in Java EE 8 as the MVC Expert Group (JSR 371
) is in the process of introducing a new CDI custom scope
) to support redirect.
The idea is simple; an MCV controller can decide to redirect a client to a specific URL, to a specific controller method. A typical example would be that an anonymous user hits a page that required to be logged; the controller will then redirect the user to a login page. To do this, the controller uses HTTP 302 ('moved temporarily')
to invite the client to make a new request to a different URL, to a different controller. That second request implies a new (and thus different) request-response cycle. And that's the 'raison-d'être' of this new @RedirectScoped
scope, i.e. to allow maintaining some state between the 2 request-response cycles of a redirect. Note that this new scope is for the MVC API only. That new scope is sometime referred as the 'Flash scope'. You can see how both redirect and @RedirectScoped
The great thing about this new scope is that it is just a new CDI custom scope. This is a great example on how the Java EE Platform leverages its foundation to evolve.