There was a *lot* of discussion abou this. Check archives for more.
Craig McClanahan has put it nicely together:
(1) Request Lifetime
Use this technique to pass beans that are relevant to this particular
request to a bean you are calling through a request dispatcher (using
either "include" or "forward"). This bean will disappear after
processing this request has been completed.
SERVLET:
request.setAttribute("theBean", myBean);
RequestDispatcher rd =
getServletContext().getRequestDispatcher('/thepage.jsp");
rd.forward(request, response);
JSP PAGE:
<jsp:useBean id="theBean" scope="request" class="....." />
(2) Session Lifetime
Use this technique to pass beans that are relevant to a particular
session (such as in individual user login) over a number of requests.
This bean will disappear when the session is invalidated or it times
out, or when you remove it.
SERVLET:
HttpSession session = request.getSession(true);
session.putValue("theBean", myBean);
/* You can do a request dispatcher here,
or just let the bean be visible on the
next request */
JSP PAGE:
<jsp:useBean id="theBean" scope="session" class="..." />
(3) Application LIfetime
Use this technique to pass beans that are relevant to all servlets and
JSP pages in a particular app, for all users. For example, I use this
to make a JDBC connection pool object available to the various servlets
and JSP pages in my apps. This bean will disappear when the servlet
engine is shut down, or when you remove it.
SERVLET:
getServletContext().setAttribute("theBean", myBean);
JSP PAGE:
<jsp:useBean id="theBean" scope="application" class="..." />
Augusto Sellhorn wrote:
> I'm not %100 percent sure about all the meanings in the scope value
> for the <jsp:useBean> tag, specially "application". Anybody know what they
> mean, or where they are explained ? I've looked all over but no luck.
>
> Thanks
> ----------
> Message To Spammers -- Game Over! Get spam-free email at http://www.MsgTo.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
--
David Mossakowski [EMAIL PROTECTED]
Programmer 212.310.7275
Instinet Corporation
"I don't sit idly by, I'm planning a big surprise"
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html