I have a login.java servlet and, as its name suggests, it provides login features for my web application Does.
I am a newbie and I am using EJB 3.1 and EE6. I do not have any logic in my login bin.java ebj and there is no other parameter (email, password etc.).
At some point in the servlet code, I have been asked to instantiate my EJB:
@EJB Login Bean Login; I would like to know if this is possible (and how) to call other producers instead of zero-arguments.
Thank you very much. Cheers.
You do not want to do this. The same servicelet is shared among all users, so EJB is also shared among all users. You do not want to store user-specific data in the servlet or EJB class instance instances. All this webpage will be shared among visitors.
Instead of converting the arguments into an EJB method, which you include in the doPost () login servlet's method. user user = loginBean.login (username, password); and then it was stored in the HTTP session when it succeeded
request.getSession (). SetAttribute ("user", user); So that the rest of your webpage may prevent you to determine whether the user is logged in or not.
if (request.getSession () .getAttribute ("user")! = Null) {// user is logged in.} Else {// user is not logged in.}
Comments
Post a Comment