A couple of comments intermixed.
On Fri, 11 Feb 2005 14:18:49 +0100, Matthias Wessendorf <[EMAIL PROTECTED]> wrote: > Sean, > > thanks for your replay > > Sean Schofield wrote: > > Matthias, > > > > Its true that object creation can be expensive but you also have to > > consider how often the underlying data (assuming it comes from a > > database) changes. In Struts you have ActionForms which are > > essentially request scope beans (similar to but not the same as > > backing beans). Its no big deal constantly creating these every > > sure not similar, since backing beans has more *features* > as only being a "form-bean". Btw. scope attribute's value > of <action/> is "session" as default. > That fact was solely for backwards compatibility with pre-1.0 versions of Struts. It should have defaulted to request scope all along. > > request. > > > > You also want to consider that session beans take up server memory. > > If you have ten different backing beans for ten different pages you > > will have ten beans sitting around in memory for each user that goes > > through those ten pages (until the session expires.) > > ah, yes good point! thanks. > > > In my application we are going to have to use a lot of request scope > > beans beacause the data needs to be up to date. It can be changed by > > That is also the thing that I wanted to do! But my co-worker said: > "make them to session, sicne creation is VERY expensive" > VERY is, of course, relative :-). It's also something that has changed dramatically in more recent JVMs (especially 1.4), to the point where the cost of object creation should not be the determining factor in which scope you use in today's apps. Using request scope beans for per-request data is both a natural fit (minimizing resource usage in between requests), but it has another benefit as well -- it eliminates any need to be concerned about thread safety in accessing these beans and their properties. If you use session scoped stuff, there is always the possibility that the user will fire off rmore than one request on the same session, and you have to be ready to deal with that. My recommendation is to use request scope for backing beans in a JSF application, storing stuff in session and appiication scope only where it's needed: * Session scope for per-user state that changes, or for passing data across requests (as an alternative to having to save and restore the data yourself). * Application scope for caching things like arrays of SelectItems that back a dropdown list, but are shared across all users. Craig > --> reason for my mail > > > other users at any time, so we want to show the latest on every > > request. In theory you could have a session bean to avoid recreating > > the object and use a scheme to repopulate it but I am not wild about > > that. > > Ok, thanks! > > I remember that Craig also allways mentioned request instead of session, > but couldn't find a thread on that... > > -Matthias > > > > Anyways that is my .02, > > > > sean > > > > > > On Fri, 11 Feb 2005 11:35:16 +0100, Matthias Wessendorf > > <[EMAIL PROTECTED]> wrote: > > > >>Hi all, > >> > >>I am just on reading [1]. There is mentioned, that > >>object creation is very expensive and you should better > >>reuse objects instead of creating them often. > >> > >>Now I thought about scope of my backing beans. > >>What should be better request or session? > >> > >>If I have request scoped backing beans that > >>get often created by ONE user and I have MANY > >>users... will request scope slow down my web app? > >> > >>Ok... application is also there, but that is > >>an other stage :-) I would use such a backing > >>bean only for *knowing* about ALL users logged > >>into the application. > >> > >>[1] http://www.oreilly.com/catalog/javapt/chapter/ch04.html > >> > >> > >>-Matthias > >> > > > > > > -- > Matthias We�endorf > Aechterhoek 18 > DE-48282 Emsdetten > Germany > phone: +49-2572-9170275 > cell phone: +49-179-1118979 > email: matzew AT apache DOT org > url: http://www.wessendorf.net > callto://mwessendorf (Skype) > icq: 47016183 > > -- > Matthias We�endorf > Aechterhoek 18 > DE-48282 Emsdetten > Germany > phone: +49-2572-9170275 > cell phone: +49-179-1118979 > email: matzew AT apache DOT org > url: http://www.wessendorf.net > callto://mwessendorf (Skype) > icq: 47016183 >

