TrainBeaser for iPhone
The moose likes JSP and the fly likes application scope Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "application scope" Watch "application scope" New topic
Author

application scope

Erik Lindholm
Greenhorn

Joined: Feb 26, 2002
Posts: 18
I use this in one of my JSPs:
<jsp:useBean id="MyBean" class="mypackage.MyBean" scope="application" />
My question is:
What would this code be if I should code the same in a Servlet ?
Tina Coleman
Ranch Hand

Joined: Dec 12, 2001
Posts: 150
So, your intended effect is you want all requests to the servlet to be able to access the same MyBean instance? Two possible solutions, I believe.
The first solution would to make MyBean a member of your servlet class. Then, all requests to your servlet would go through your servlet instance, and thus would have access to MyBean.
The second solution would be to put MyBean into the ServletContext, where it can then be shared by _all_ servlets in the servlet engine (or, according to my copy of Marty Hall's book, "or in the Web application, if your server supports such a capability").
 
 
subject: application scope
 
Threads others viewed
access the instance of a class in another class?
where to go j2ee or j2me
Sharing instances of a bean between JSP files
Context Parameters
Cannot Find Bean in Scope Request
developer file tools