Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
10.2 JSP Expressions
235
session
, the 
HttpSession
 associated with the request (unless 
disabled with the 
session
 attribute of the 
page
 directive   see 
Section 11.4)
out
, the 
PrintWriter
 (a buffered version called 
JspWriter
) 
used to send output to the client
Here is an example: 
Your hostname: <%= request.getRemoteHost() %>
XML Syntax for Expressions
XML authors can use the following alternative syntax for JSP expressions: 
Java Expression
Note that XML elements, unlike HTML ones, are case sensitive, so be
sure to use 
jsp:expression
 in lower case. 
Using Expressions as Attribute Values
As we will see later, JSP includes a number of elements that use XML syntax
to specify various parameters. For example, the following example passes
"Marty"
 to the 
setFirstName
 method of the object bound to the 
author
variable. Don't worry if you don't understand the details of this code; it is dis 
cussed in detail in Chapter 13 (Using JavaBeans with JSP). My purpose here
is simply to point out the use of the 
name
, 
property
, and 
value
 attributes.
property="firstName"
value="Marty" />
Most attributes require the value to be a fixed string enclosed in either sin 
gle or double quotes, as in the example above. A few attributes, however, per 
mit you to use a JSP expression that is computed at request time. The 
value
attribute of 
jsp:setProperty
 is one such example, so the following code is
perfectly legal:
property="id"
value='<%= "UserID" + Math.random() %>' />
Table 10.1 lists the attributes that permit a request time value as in this
example. 
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