Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
244
Chapter 10 JSP Scripting Elements
Special Declaration Syntax
As with scriptlets, if you want to use the characters 
%>
, enter 
%\>
 instead.
Finally, note that the XML equivalent of 
<%! Code %>
 is 
Code
10.5 Predefined Variables
To simplify code in JSP expressions and scriptlets, you are supplied with eight
automatically defined variables, sometimes called implicit objects. Since JSP
declarations (see Section 10.4) result in code that appears outside of the
_jspService
 method, these variables are not accessible in declarations. The
available variables are 
request
, 
response
, 
out
, 
session
, 
application
,
config
, 
pageContext
, and 
page
. Details for each are given below. 
request
This variable is the 
HttpServletRequest
 associated with the request; 
it gives you access to the request parameters, the request type (e.g., 
GET
or 
POST
), and the incoming HTTP headers (e.g., cookies). Strictly 
speaking, if the protocol in the request is something other than HTTP, 
request
 is allowed to be a subclass of 
ServletRequest
 other than 
HttpServletRequest
. However, few, if any, JSP servers currently sup 
port non HTTP servlets. 
response
This variable is the 
HttpServletResponse
 associated with the 
response to the client. Note that since the output stream (see 
out
) is 
normally buffered, it is legal to set HTTP status codes and response 
headers in JSP pages, even though the setting of headers or status codes 
is not permitted in servlets once any output has been sent to the client. 
out
This is the 
PrintWriter
 used to send output to the client. However, to 
make the 
response
 object useful, this is a buffered version of 
Print 
Writer
 called 
JspWriter
. You can adjust the buffer size through use of 
the 
buffer
 attribute of the 
page
 directive (see Section 11.5). Also note 
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