This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
If I specify the scope of the Managed bean as "Session" in faces-config.xml, then I believe the container will create "One" instance of the MB per Session. Is that correct??
Ok, if that is correct. I am totally confused here.
Here is my managed bean,
I deployed the enterprise application and run the App Server. Now, When the first Session is created ( lets say, first user logged in ), I am getting this S.O.P statement printed in the console. After that how many ever sessions created ( ie, how many ever users logged in ), I don't see the S.O.P statement in the console.
Since I specified the scope as "Session", I am expecting the S.O.P statement per Session Creation.
Am I missing something here??? Any thoughts.
JebaRaj.<br /> MCP, SCJP 1.5 <br />----------------------------<br /> THOUGH TIMES TEACH TRUST. <br />----------------------------
1. If you're expecting multiple sessions to be created, but you're not accessing the app from multiple computers, you won't get them. A session created in one browser window will apply to all the other browser windows. (exception, if you're running Internet Explorer and Firefox, IE will have one session and Firefox will have one session - the session is defined in each brower's cookie collection unless you disable cookies).
2. System.out.println is a very untrustworthy way to output text to a webapp console. It's not part of the standard, so not only do different appservers route it differently, the same appserver on different OS's may not route System.out the same. For anything more than a quick-and-dirty debug, it's better to use one of the logging frameworks.
Specifically, what I'm saying is that it's possible that your other println's are getting lost somewhere. But since they do tend to show up eventually, I'd consider case #1 as the likely problem.
An IDE is no substitute for an Intelligent Developer.
Joined: Sep 19, 2003
Regarding point #2, I totally agree with you. Just want to notice how many times the Constructor of the BB is called, i used SOP.
Your point #1 is valid. If that is the case, the App Server creates BB instance per Browser Type ( thinks that each browser type (IE or Firefox) instance is a new session ). I am confused here.
Ok, lets take the normal "Shopping Cart Application". I assume each User login will be considered as new Session. But this contradict to your Point #1. If i dont close the browser window and login-logout with five different user, then will the App Server creates only one BB instance??
If that is correct, then i am forced to believe that the definition of session by App Server is different from what we normally consider in Shopping Cart Application. Is that true?
So, the managed-bean-scope that we are defining in faces-config.xml file is more for App Server's session definition and not the sessions (HttpSession) that we create,manage,destroy in the Application. Is that corret?
Can you clear me on this, I think i have missed out some basic knowledge towards the Session?