This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "scope of bean instances" Watch "scope of bean instances" New topic
Author

scope of bean instances

shikhar singh
Ranch Hand

Joined: Oct 02, 2000
Posts: 31
Hi,
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
shikhar singh
Ranch Hand

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

Joined: Mar 22, 2000
Posts: 12759
    
    5
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.
Bill

------------------
author of:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: scope of bean instances
 
Similar Threads
jsp usebean sharing issues
problem with registration page
useBean with different scope on the same bean?
Question about Java Beans
About jsp:useBean tag