0

In my project I have a @Stateful UserSessionData bean that only stores user data. Upon a user logging in, it gets brought forth with a JNDI lookup, populated, and stored in a HttpSession attribute. My question is: shouldn't I instead create a @SessionScoped UserSessionData CDI bean and inject and populate it in my login bean? Then I can inject it in the backing beans that need the data instead of using HttpSession.getAttribute. What is the preferred method?

John
  • 23
  • 1
  • 8
  • 1
    This question is poorly thought out. You're technically asking `@Stateful` EJB vs `@SessionScoped` managed bean. They are absolutely not interchangeable. It looks like you don't at all understand the point of having an EJB. The duplicate should make you realize that your current question doesn't make any sense. The correct approach is by the way to just inject that EJB in a normal session scoped bean instead of manually fiddling with JNDI and HTTP session. – BalusC May 11 '16 at 07:22
  • @BalusC 1. I didn't code it and when I saw it today it didn't look right to me. 2. I figured the session scoped bean was probably the correct choice but I wanted to confirm. Especially since that bad piece of code had been sitting there for a couple of years. – John May 11 '16 at 08:41

0 Answers0