File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes scope of bean instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "scope of bean instances" Watch "scope of bean instances" New topic

scope of bean instances

shikhar singh
Ranch Hand

Joined: Oct 02, 2000
Posts: 31
I've an application which have aroud 800 JSP files which accesses around 800 beans.(approx 3-5 beans per page). At present the scope of the beans given by us is "page". So everytime the different JSP page is requested, which uses beans which were used previously used, it garbage collects the previous instance and creates a new one.
What if I make the scope of all the beans as "session" and use it across most of JSPs with the same ID. Will this approach improve the performance? And also will all the requests(for different JSPs) will be using the same instance of Bean and if yes, whether it will be syncronized? And does client has to wait if the instance is already in use?
Thanks in advance
shikhar singh
Ranch Hand

Joined: Oct 02, 2000
Posts: 31
Can somebody pl help me on this issue.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
If you make the scope of the bean "session", it will hang around between request/response cycles instead of being destroyed after each page. The only way I can imagine a conflict over a session bean would be if a user has two requests in action (such as from a frame) as I understand it, you would have to handle any synchronization in the bean.

author of:
I agree. Here's the link:
subject: scope of bean instances
It's not a secret anymore!