Meaningless Drivel is fun!*
The moose likes JSF and the fly likes Managed Benan Instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Managed Benan Instance" Watch "Managed Benan Instance" New topic
Author

Managed Benan Instance

Chris Jebaraj
Ranch Hand

Joined: Sep 19, 2003
Posts: 34
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 />----------------------------
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

I can see two possibilities.

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Chris Jebaraj
Ranch Hand

Joined: Sep 19, 2003
Posts: 34
Hi Tim,

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Managed Benan Instance
 
Similar Threads
Cant store data in database table Hibernat/Spring/JSF
Injecting Beans as Parameters (Injected Bean reference is null)
Passing data between beans
JSF Backing bean code
Get a ArrayList containing the union of two different sized arraylist of some object type