Search code examples
servletsejbconversation-scope

How to post to a conversation scope bean or access this bean from a servlet


The scenario, I have a client website that needs to post data to the server website. During the post, the server open a login page to authenticate the client and after successful authentication store the data in the database.

I'm using javaee6, jsf, ejb.

Questions: 1.) I'm posting on a servlet but can't get a hold of the conversation scope bean, so that I can show the posted data on the login screen at the same time store in the conversation scope bean. After successful login get the data from the bean and store in the database.

2.) Can I post directly to a page, with a conversation scope backing bean?

3.) A friend of mine mentioned jaas, but doesn't have time to explain well. Can I use this tech?

Thanks,
czetsuya


Solution

  • The solution I come up with this, is to read the posted parameters in the managed bean's post construct method:

    @PostConstruct
    public void init() {
        if (FacesContext.getCurrentInstance() != null) {
            ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
            Map<String, String> requestParameters = context.getRequestParameterMap();
            if (requestParameters != null) {
                beginConversation();
            }
        }
    }