| 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
|
|
|