Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
10.5 Predefined Variables
245
that 
out
 is used almost exclusively in scriptlets, since JSP expressions 
are automatically placed in the output stream and thus rarely need to 
refer to 
out
 explicitly. 
session
This variable is the 
HttpSession
 object associated with the request. 
Recall that sessions are created automatically, so this variable is bound 
even if there is no incoming session reference. The one exception is if 
you use the 
session
 attribute of the 
page
 directive (see Section 11.4) 
to turn sessions off. In that case, attempts to reference the 
session
variable cause errors at the time the JSP page is translated into a servlet. 
application
This variable is the 
ServletContext
 as obtained via 
getServletCon 
fig().getContext()
. Servlets and JSP pages can store persistent data 
in the 
ServletContext
 object rather than in instance variables. 
Serv 
letContext
 has 
setAttribute
 and 
getAttribute
 methods that let 
you store arbitrary data associated with specified keys. The difference 
between storing data in instance variables and storing it in the 
Servlet 
Context
 is that the 
ServletContext
 is shared by all servlets in the serv 
let engine (or in the Web application, if your server supports such a 
capability). For more information on the use of the 
ServletContext
, 
see Section 13.4 (Sharing Beans) and Chapter 15 (Integrating Servlets 
and JSP).
config
This variable is the 
ServletConfig
 object for this page. 
pageContext
JSP introduced a new class called 
PageContext
 to give a single point of 
access to many of the page attributes and to provide a convenient place 
to store shared data. The 
pageContext
 variable stores the value of the 
PageContext
 object associated with the current page. See Section 13.4 
(Sharing Beans) for a discussion of its use.
page
This variable is simply a synonym for 
this
 and is not very useful in the 
Java programming language. It was created as a place holder for the 
time when the scripting language could be something other than Java. 
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved