On Wed, 19 Apr 2000, Arnab Acharya wrote:
> Could anyone tell me, preferably with examples, the difference btwn session
> and page scope?
No example here, because I just woke up, but here's the difference between
all the scopes:
With page scope, the bean is available only during the lifetime of that
JSP page. When the JSP page execution ends (for whatever reason), the bean
reference is lost.
With request scope, the bean is available until the last JSP servicing
this request ends. Thus, a page executed via <jsp:forward /> still has
access to the beans (provided, of course, they declare the reference
themselves via <jsp:useBean />).
With session scope, the bean reference is available until the user session
ends, which is configurable in the web server (and controllable by the
programmer, as well.) Thus, if a user puts in a name, a session bean can
retain that data until the user leaves the site altogether for an hour or
so, or until they specifically log out (or create a new session for
whatever reason.)
With application scope, the bean reference is available to any servlet or
JSP page that executes within the same servlet context as the bean (i.e.,
the same web application.) This might be used for (bad example) page hits
during the application's current execution, or something like that. I
would say "Database connections," but I'm SURE you're using J2EE and
letting your container pool the connections itself... right?
-----------------------------------------------------------
Joseph B. Ottinger [EMAIL PROTECTED]
http://cupid.suninternet.com/~joeo HOMES.COM Developer
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets