I'm working (mostly) with @ViewScoped @Named Faces beans (javax.faces.view.ViewScoped
and javax.inject.Named
) and would like to know if from the ServletRequest (or HttpServletRequest) I can differentiate between two different instantiations of the same bean within a javax.servlet.Filter
For example, a user opens the same page in two different tabs, but both of these have the same SessionID via the call httpRequest.getSession().getId()
. Currently this is not helpful to me.
Alternatively I have access to the Thread ID, but this changes with each ajax call, and I need to keep around something unique for just the instance of the backing bean across all calls.. until the bean is destroyed.
So, something like this (this doesn't work, but hopefully illustrates my need)
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
try
{
HttpServletRequest httpRequest = (HttpServletRequest) request;
// not real code, but this is what I'm looking for;
// get a unique identifier for just this instance of the bean that stays the same across all ajax requests
String beanId = request.getCurrentBackingBean.getInstanceId();
...