Usually I use Java EE authentication with a custom login form and beans in my project. So I configure Glassfish to get user/password from a database (JDBC), create a jsf form that calls a login() method on a RequestScoped bean (named "LoginBean"), that calls HttpServletRequest's login() method.
When the login attempt succeeds, I set the user information in a SessionScoped bean that was injected in LoginBean, which I named "LoginService". And then, in lots of other website pages and beans I use this data by always injecting LoginService and acessing it's data.
All is fine, but I noticed that a Session is being created if a user goes to the login page, even if it hasn't attempted a login yet. My guess is that it happens because LoginService is injected in LoginBean always, on the object creation.
And because of that I have 2 questions:
- Should I care about this session? Can this cause any problems?
- What is the best way to do this custom login without creating a session every time a user access the login page? I mean, I could pass user info on a querystring after succeding, but that would be horrible. :)
Thx.