So where does one declare application scope stuff? Is there a special file
for this?
I suppose the answer could be in the first JSP that is entered, but what if
there is no single JSP that is the entry point? Or what if it's necessary to
have both page scope and application scope in the same page? Can an
individual variable be declared application, session, or page?
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Craig R. McClanahan
Sent: Wednesday, December 01, 1999 1:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Definition of scope lifecycle/times
Daniel Tillin wrote:
> Does anyone know of any documentation which defines the
> lifecycle/times of scopes for JSPs?Cheers Dan
One way to understand these scopes more clearly is to review the servlet
API specification, and the associated books and tutorials. The concepts
match up like this (and in fact servlets and JSP pages can share data by
taking advantage of the relationships):
Scope=Page has no direct analog in servlets - think of it as local
variables that last only for the length of the current call.
Scope=Request === Servlet request attributes. They are useful when you
use a servlet to process form parameters, do something, and then use
RequestDispatcher.forward() to forward control to a JSP page to display
the results. It also allows you to pass additional stuff to a
servlet/JSP that is included with <jsp:include> or
RequestDispatcher.include().
Scope=Session === Session attributes (used to be called session values,
but the names are being changed in the 2.2 spec). These objects are the
place to save state between requests for a particular user. For
example, an e-commerce site shopping cart would save things like your
currently selected items here.
Scope=Application === Servlet context attributes. This is where you
want to store "global variables" for your application -- objects that
need to be shared across multiple JSP pages and/or servlets. An example
would be a JDBC connection pool. Typically, such objects are
initialized in a startup servlet and then remain available through the
life of the server, but this is not required.
Craig McClanahan
===========================================================================
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
===========================================================================
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