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

jsp:useBean and scope

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

If a bean already exists, will jsp:useBean use it regardless of the scope in which it is present? or will it use the bean only if it is present in the scope specified by its scope attribute. Because I have a jsp page which I am trying to analyze for performance, its part of a whole project which I do not have access to. I want to know if the bean used by this jsp through its <jsp:useBean> is the same bean used by the rest of the project. Thanks.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The container should treat beans with the same name but bound to different scopes differently. I know that in Tomcat version 5.0.28, this was not the case. In that version, the jsp.getProperty tags used the same mechanism for finding scoped variables that EL expressions would (search all scopes for the object with the given name).

This was tightened up in later versions.

You may want to do some testing before relying on this behavior in your own app.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: jsp:useBean and scope
It's not a secret anymore!