<?xml version="1.0" encoding="utf-8"?>
<news>
	<eligbleviewers id="eligbl1" newstosee="3">
		<newsitem id="2862224685" hide="0">
			<date>January  20, 2008</date>
			<title>Java Enterprise Edition 5 (Java EE 5)</title>
			<abstract>Java Platform, Enterprise Edition or Java EE is a widely used platform for server programming in the Java programming language. The Java platform (Enterprise Edition) differs from the Java Standard Edition Platform (Java SE) in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier Java software, based largely on modular components running on an application server.</abstract>
			<aff_link>
			<![CDATA[
				<a href="http://www.linkconnector.com/traffic_affiliate.php?lc=031805035526003764&lcpt=0&lcpf=3" target="_blank"><img src="http://www.linkconnector.com/traffic_record.php?lc=031805035526003764"  border="0" alt="PRWeb"></a>
			]]>
			</aff_link>
			<description>&lt;p&gt;Developers today increasingly recognize the need for distributed, transactional, and portable applications that
leverage the speed, security, and reliability of server-side technology. In the world of
information technology, enterprise applications must be designed, built, and produced for less money,
with greater speed, and with fewer resources.&lt;/p&gt;&lt;p&gt;With the Java&lt;sup&gt;TM&lt;/sup&gt; Platform, Enterprise Edition (Java EE), development of Java enterprise applications
has never been easier or faster. The aim of the Java EE 5
platform is to provide developers a powerful set of APIs while reducing development
time, reducing application complexity, and improving application performance.&lt;/p&gt;&lt;p&gt;The Java EE 5 platform introduces a simplified programming model. With Java EE
5 technology, XML deployment descriptors are now optional. Instead, a developer can simply
enter the information as an annotation directly into a Java source file, and
the Java EE server will configure the component at deployment and runtime. These
annotations are generally used to embed in a program data that would otherwise
be furnished in a deployment descriptor. With annotations, the specification information is put
directly in your code next to the program element that it affects.&lt;/p&gt;&lt;p&gt;In the Java EE platform, dependency injection can be applied to all resources
that a component needs, effectively hiding the creation and lookup of resources from
application code. Dependency injection can be used in EJB containers, web containers, and
application clients. Dependency injection allows the Java EE container to automatically insert references
to other required components or resources using annotations.&lt;/p&gt;&lt;p&gt;The Java Persistence API is new to the Java EE 5 platform. The
Java Persistence API provides an object/relational mapping for managing relational data in enterprise
beans, web components, and application clients. It can also be used in Java
SE applications, outside of the Java EE environment.&lt;/p&gt;&lt;p&gt;This tutorial uses examples to describe the features and functionalities available in the
Java EE 5 platform for developing enterprise applications. Whether you are a new
or experienced Enterprise developer, you should find the examples and accompanying text a
valuable and accessible knowledge base for creating your own solutions.&lt;/p&gt;&lt;p&gt;If you are new to Java EE enterprise application development, this chapter is
a good place to start. Here you will review development basics, learn
about the Java EE architecture and APIs, become acquainted with important terms and concepts,
and find out how to approach Java EE application programming, assembly, and deployment.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="1597174412" hide="0">
			<date>January  20, 2008</date>
			<title>Java EE Application Model</title>
			<description>&lt;p&gt;The Java EE application model begins with the Java programming language and the
Java virtual machine. The proven portability, security, and developer productivity they provide forms
the basis of the application model. Java EE is designed to support applications
that implement enterprise services for customers, employees, suppliers, partners, and others who make
demands on or contributions to the enterprise. Such applications are inherently complex, potentially accessing
data from a variety of sources and distributing applications to a variety of
clients.&lt;/p&gt;&lt;p&gt;To better control and manage these applications, the business functions to support these
various users are conducted in the middle tier. The middle tier represents an
environment that is closely controlled by an enterprise’s information technology department. The middle
tier is typically run on dedicated server hardware and has access to the
full services of the enterprise.&lt;/p&gt;&lt;p&gt;The Java EE application model defines an architecture for implementing services as multitier
applications that deliver the scalability, accessibility, and manageability needed by enterprise-level applications. This
model partitions the work needed to implement a multitier service into two parts:
the business and presentation logic to be implemented by the developer, and the
standard system services provided by the Java EE platform. The developer can rely
on the platform to provide solutions for the hard systems-level problems of developing a
multitier service.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="13479781032" hide="0">
			<date>January  20, 2008</date>
			<title>Distributed Multitiered Applications</title>
			<description>&lt;p&gt;The Java EE platform uses a distributed multitiered application model for 
	enterprise applications. Application logic is divided into components according 
	to function, and the various application components that make up a Java EE 
	application are installed on different machines depending on the tier in the 
	multitiered Java EE environment to which the application component belongs.
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnaaz"&gt;Figure 1-1&lt;/a&gt;
	shows two multitiered Java EE applications divided into the tiers described in 
	the following list. The Java EE application parts shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnaaz"&gt;
		Figure 1-1&lt;/a&gt; are presented in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnabb"&gt;
		Java EE Components&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Client-tier components run on the client machine.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Web-tier components run on the Java EE server.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Business-tier components run on the Java EE server.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enterprise information system (EIS)-tier software runs on the EIS server.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-5"&gt;&lt;/a&gt;Although a Java EE application can consist of the 
	three or four tiers shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnaaz"&gt;
		Figure 1-1&lt;/a&gt;, Java EE multitiered applications are generally considered 
	to be three-tiered applications because they are distributed over three 
	locations: client machines, the Java EE server machine, and the database or 
	legacy machines at the back end. Three-tiered applications that run in this way 
	extend the standard two-tiered client and server model by placing a 
	multithreaded application server between the client application and back-end 
	storage.&lt;/p&gt;
&lt;a name="bnaaz"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-1 Multitiered Applications&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-multitieredApplications.gif"
	alt="Diagram of multitiered application structure, including client tier, web tier, business tier, and EIS tier."&gt;
&lt;a name="bnaba"&gt;&lt;/a&gt;
&lt;h4&gt;Security&lt;/h4&gt;
&lt;p&gt;While other enterprise application models require platform-specific security 
	measures in each application, the Java EE security environment enables security 
	constraints to be defined at deployment time. The Java EE platform makes 
	applications portable to a wide variety of security implementations by 
	shielding application developers from the complexity of implementing security 
	features.&lt;/p&gt;
&lt;p&gt;The Java EE platform provides standard declarative access control rules that are 
	defined by the developer and interpreted when the application is deployed on 
	the server. Java EE also provides standard login mechanisms so application 
	developers do not have to implement these mechanisms in their applications. The 
	same application works in a variety of different security environments without 
	changing the source code.&lt;/p&gt;
&lt;a name="bnabb"&gt;&lt;/a&gt;
&lt;h4&gt;Java EE Components&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-6"&gt;&lt;/a&gt;&lt;a name="indexterm-7"&gt;&lt;/a&gt;Java EE applications are 
	made up of components. A Java EE component is a self-contained functional 
	software unit that is assembled into a Java EE application with its related 
	classes and files and that communicates with other components.
&lt;/p&gt;
&lt;p&gt;The Java EE specification defines the following Java EE components:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Application clients and applets are components that run on the client.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Java Servlet, JavaServer Faces, and JavaServer Pages&lt;sup&gt;TM&lt;/sup&gt; (JSP&lt;sup&gt;TM&lt;/sup&gt;) 
			technology components are web components that run on the server.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enterprise JavaBeans&lt;sup&gt;TM&lt;/sup&gt; (EJB&lt;sup&gt;TM&lt;/sup&gt;) components (enterprise 
			beans) are business components that run on the server.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Java EE components are written in the Java programming language and are compiled 
	in the same way as any program in the language. The difference between Java EE 
	components and “standard” Java classes is that Java EE components are assembled 
	into a Java EE application, are verified to be well formed and in compliance 
	with the Java EE specification, and are deployed to production, where they are 
	run and managed by the Java EE server.&lt;/p&gt;
&lt;a name="bnabc"&gt;&lt;/a&gt;
&lt;h4&gt;Java EE Clients&lt;/h4&gt;
&lt;a name="indexterm-8"&gt;&lt;/a&gt;
&lt;p&gt;A Java EE client can be a web client or an application client.&lt;/p&gt;
&lt;a name="bnabd"&gt;&lt;/a&gt;
&lt;h5&gt;Web Clients&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-9"&gt;&lt;/a&gt;&lt;a name="indexterm-10"&gt;&lt;/a&gt;A &lt;b&gt;web client&lt;/b&gt; consists 
	of two parts: (1) dynamic web pages containing various types of markup language 
	(HTML, XML, and so on), which are generated by web components running in the 
	web tier, and (2) a web browser, which renders the pages received from the 
	server.&lt;/p&gt;
&lt;p&gt;A web client is sometimes called a thin client. Thin clients usually do not 
	query databases, execute complex business rules, or connect to legacy 
	applications. When you use a thin client, such heavyweight operations are 
	off-loaded to enterprise beans executing on the Java EE server, where they can 
	leverage the security, speed, services, and reliability of Java EE server-side 
	technologies.&lt;/p&gt;
&lt;a name="bnabe"&gt;&lt;/a&gt;
&lt;h5&gt;Applets&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-11"&gt;&lt;/a&gt;A web page received from the web tier can include an 
	embedded applet. An &lt;b&gt;applet&lt;/b&gt; is a small client application written in the 
	Java programming language that executes in the Java virtual machine installed 
	in the web browser. However, client systems will likely need the Java Plug-in 
	and possibly a security policy file for the applet to successfully execute in 
	the web browser.&lt;/p&gt;
&lt;p&gt;Web components are the preferred API for creating a web client program because 
	no plug-ins or security policy files are needed on the client systems. Also, 
	web components enable cleaner and more modular application design because they 
	provide a way to separate applications programming from web page design. 
	Personnel involved in web page design thus do not need to understand Java 
	programming language syntax to do their jobs.&lt;/p&gt;
&lt;a name="bnabf"&gt;&lt;/a&gt;
&lt;h5&gt;Application Clients&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-12"&gt;&lt;/a&gt;&lt;a name="indexterm-13"&gt;&lt;/a&gt;&lt;a name="indexterm-14"&gt;&lt;/a&gt;An
	&lt;b&gt;application client&lt;/b&gt; runs on a client machine and provides a way for users 
	to handle tasks that require a richer user interface than can be provided by a 
	markup language. It typically has a graphical user interface (GUI) created from 
	the Swing or the Abstract Window Toolkit (AWT) API, but a command-line 
	interface is certainly possible.&lt;/p&gt;
&lt;p&gt;Application clients directly access enterprise beans running in the business 
	tier. However, if application requirements warrant it, an application client 
	can open an HTTP connection to establish communication with a servlet running 
	in the web tier. Application clients written in languages other than Java can 
	interact with Java EE 5 servers, enabling the Java EE 5 platform to 
	interoperate with legacy systems, clients, and non-Java languages.&lt;/p&gt;
&lt;a name="bnabg"&gt;&lt;/a&gt;
&lt;h5&gt;The JavaBeans&lt;sup&gt;TM&lt;/sup&gt; Component Architecture&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-15"&gt;&lt;/a&gt;The server and client tiers might also include 
	components based on the JavaBeans component architecture (JavaBeans components) 
	to manage the data flow between an application client or applet and components 
	running on the Java EE server, or between server components and a database. 
	JavaBeans components are not considered Java EE components by the Java EE 
	specification.&lt;/p&gt;
&lt;p&gt;JavaBeans components have properties and have &lt;tt&gt;get&lt;/tt&gt; and &lt;tt&gt;set&lt;/tt&gt; methods 
	for accessing the properties. JavaBeans components used in this way are 
	typically simple in design and implementation but should conform to the naming 
	and design conventions outlined in the JavaBeans component architecture.&lt;/p&gt;
&lt;a name="bnabh"&gt;&lt;/a&gt;
&lt;h5&gt;Java EE Server Communications&lt;/h5&gt;
&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnabi"&gt;Figure 1-2&lt;/a&gt;
	shows the various elements that can make up the client tier. The client 
	communicates with the business tier running on the Java EE server either 
	directly or, as in the case of a client running in a browser, by going through 
	JSP pages or servlets running in the web tier.&lt;/p&gt;
&lt;a name="bnabi"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-2 Server Communication&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-serverCommunications.gif"
	alt="Diagram of client-server communication. Application clients access the business tier directly. Browsers, web pages, and applets access the web tier."&gt;&lt;p&gt;&lt;a name="indexterm-16"&gt;&lt;/a&gt;Your 
	Java EE application uses a thin browser-based client or thick application 
	client. In deciding which one to use, you should be aware of the trade-offs 
	between keeping functionality on the client and close to the user (thick 
	client) and off-loading as much functionality as possible to the server (thin 
	client). The more functionality you off-load to the server, the easier it is to 
	distribute, deploy, and manage the application; however, keeping more 
	functionality on the client can make for a better perceived user experience.&lt;/p&gt;
&lt;a name="bnabj"&gt;&lt;/a&gt;
&lt;h4&gt;Web Components&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-17"&gt;&lt;/a&gt;&lt;a name="indexterm-18"&gt;&lt;/a&gt;Java EE web components are 
	either servlets or pages created using JSP technology (JSP pages) and/or 
	JavaServer Faces technology. &lt;b&gt;Servlets&lt;/b&gt; are Java programming language 
	classes that dynamically process requests and construct responses. &lt;b&gt;JSP pages&lt;/b&gt;
	are text-based documents that execute as servlets but allow a more natural 
	approach to creating static content. &lt;b&gt;JavaServer Faces&lt;/b&gt; technology builds 
	on servlets and JSP technology and provides a user interface component 
	framework for web applications.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-19"&gt;&lt;/a&gt;&lt;a name="indexterm-20"&gt;&lt;/a&gt;&lt;a name="indexterm-21"&gt;&lt;/a&gt;Static 
	HTML pages and applets are bundled with web components during application 
	assembly but are not considered web components by the Java EE specification. 
	Server-side utility classes can also be bundled with web components and, like 
	HTML pages, are not considered web components.&lt;/p&gt;
&lt;p&gt;As shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnabm"&gt;
		Figure 1-3&lt;/a&gt;, the web tier, like the client tier, might include a 
	JavaBeans component to manage the user input and send that input to enterprise 
	beans running in the business tier for processing.&lt;/p&gt;
&lt;a name="bnabm"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-3 Web Tier and Java EE Applications&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-webTier.gif"
	alt="Diagram of client-server communication showing detail of JavaBeans components and JSP pages in the web tier."&gt;
&lt;a name="bnabk"&gt;&lt;/a&gt;
&lt;h4&gt;Business Components&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-22"&gt;&lt;/a&gt;&lt;a name="indexterm-23"&gt;&lt;/a&gt;Business code, which is 
	logic that solves or meets the needs of a particular business domain such as 
	banking, retail, or finance, is handled by enterprise beans running in the 
	business tier. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaay.html#bnabn"&gt;
		Figure 1-4&lt;/a&gt; shows how an enterprise bean receives data from client 
	programs, processes it (if necessary), and sends it to the enterprise 
	information system tier for storage. An enterprise bean also retrieves data 
	from storage, processes it (if necessary), and sends it back to the client 
	program.&lt;/p&gt;
&lt;a name="bnabn"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-4 Business and EIS Tiers&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-businessAndEisTiers.gif"
	alt="Diagram of client-server communication showing detail of entities, session beans, and message-driven beans in the business tier."&gt;
&lt;a name="bnabl"&gt;&lt;/a&gt;
&lt;h4&gt;Enterprise Information System Tier&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-24"&gt;&lt;/a&gt;&lt;a name="indexterm-25"&gt;&lt;/a&gt;The enterprise information 
	system tier handles EIS software and includes enterprise infrastructure systems 
	such as enterprise resource planning (ERP), mainframe transaction processing, 
	database systems, and other legacy information systems. For example, Java EE 
	application components might need access to enterprise information systems for 
	database connectivity.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="16785995828" hide="0">
			<date>January  20, 2008</date>
			<title>Java EE Containers</title>
			<description>&lt;p&gt;Normally, thin-client multitiered applications are hard to write because they 
	involve many lines of intricate code to handle transaction and state 
	management, multithreading, resource pooling, and other complex low-level 
	details. The component-based and platform-independent Java EE architecture 
	makes Java EE applications easy to write because business logic is organized 
	into reusable components. In addition, the Java EE server provides underlying 
	services in the form of a container for every component type. Because you do 
	not have to develop these services yourself, you are free to concentrate on 
	solving the business problem at hand.&lt;/p&gt;
&lt;a name="bnabp"&gt;&lt;/a&gt;
&lt;h4&gt;Container Services&lt;/h4&gt;
&lt;a name="indexterm-31"&gt;&lt;/a&gt;
&lt;p&gt;&lt;b&gt;Containers&lt;/b&gt; are the interface between a component and the low-level 
	platform-specific functionality that supports the component. Before a web, 
	enterprise bean, or application client component can be executed, it must be 
	assembled into a Java EE module and deployed into its container.&lt;/p&gt;
&lt;p&gt;The assembly process involves specifying container settings for each component 
	in the Java EE application and for the Java EE application itself. Container 
	settings customize the underlying support provided by the Java EE server, 
	including services such as security, transaction management, Java Naming and 
	Directory Interface&lt;sup&gt;TM&lt;/sup&gt; (JNDI) lookups, and remote connectivity. Here 
	are some of the highlights:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-32"&gt;&lt;/a&gt;The Java EE security model lets you configure a web 
			component or enterprise bean so that system resources are accessed only by 
			authorized users.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-33"&gt;&lt;/a&gt;The Java EE transaction model lets you specify 
			relationships among methods that make up a single transaction so that all 
			methods in one transaction are treated as a single unit.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;JNDI lookup services provide a unified interface to multiple naming and 
			directory services in the enterprise so that application components can access 
			these services.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;The Java EE remote connectivity model manages low-level communications between 
			clients and enterprise beans. After an enterprise bean is created, a client 
			invokes methods on it as if it were in the same virtual machine.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-34"&gt;&lt;/a&gt;Because the Java EE architecture provides 
	configurable services, application components within the same Java EE 
	application can behave differently based on where they are deployed. For 
	example, an enterprise bean can have security settings that allow it a certain 
	level of access to database data in one production environment and another 
	level of database access in another production environment.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-35"&gt;&lt;/a&gt;The container also manages nonconfigurable services 
	such as enterprise bean and servlet life cycles, database connection resource 
	pooling, data persistence, and access to the Java EE platform APIs (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnacj.html"&gt;
		Java EE 5 APIs&lt;/a&gt;).&lt;/p&gt;
&lt;a name="bnabq"&gt;&lt;/a&gt;
&lt;h4&gt;Container Types&lt;/h4&gt;
&lt;p&gt;The deployment process installs Java EE application components in the Java EE 
	containers as illustrated in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnabo.html#bnabr"&gt;
		Figure 1-5&lt;/a&gt;.&lt;/p&gt;
&lt;a name="bnabr"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-5 Java EE Server and Containers&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-serverAndContainers.gif"
	alt="Diagram of client-server communication showing servlets and JSP pages in the web tier and enterprise beans in the business tier."&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-36"&gt;&lt;/a&gt;&lt;b&gt;Java EE server&lt;/b&gt;: The runtime portion of a Java 
			EE product. A Java EE server provides EJB and web containers.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-37"&gt;&lt;/a&gt;&lt;b&gt;Enterprise JavaBeans (EJB) container&lt;/b&gt;: Manages 
			the execution of enterprise beans for Java EE applications. Enterprise beans 
			and their container run on the Java EE server.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-38"&gt;&lt;/a&gt;&lt;b&gt;Web container&lt;/b&gt;: Manages the execution of JSP 
			page and servlet components for Java EE applications. Web components and their 
			container run on the Java EE server.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-39"&gt;&lt;/a&gt;&lt;b&gt;Application client container&lt;/b&gt;: Manages the 
			execution of application client components. Application clients and their 
			container run on the client.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;&lt;a name="indexterm-40"&gt;&lt;/a&gt;&lt;b&gt;Applet container&lt;/b&gt;: Manages the execution of 
			applets. Consists of a web browser and Java Plug-in running on the client 
			together.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;</description>
		</newsitem>
		<newsitem id="878627672" hide="0">
			<date>January  20, 2008</date>
			<title>Web Services Support</title>
			<description>&lt;p&gt;Web services are web-based enterprise applications that use open, XML-based 
	standards and transport protocols to exchange data with calling clients. The 
	Java EE platform provides the XML APIs and tools you need to quickly design, 
	develop, test, and deploy web services and clients that fully interoperate with 
	other web services and clients running on Java-based or non-Java-based 
	platforms.&lt;/p&gt;
&lt;p&gt;To write web services and clients with the Java EE XML APIs, all you do is pass 
	parameter data to the method calls and process the data returned; or for 
	document-oriented web services, you send documents containing the service data 
	back and forth. No low-level programming is needed because the XML API 
	implementations do the work of translating the application data to and from an 
	XML-based data stream that is sent over the standardized XML-based transport 
	protocols. These XML-based standards and protocols are introduced in the 
	following sections.&lt;/p&gt;
&lt;p&gt;The translation of data to a standardized XML-based data stream is what makes 
	web services and clients written with the Java EE XML APIs fully interoperable. 
	This does not necessarily mean that the data being transported includes XML 
	tags because the transported data can itself be plain text, XML data, or any 
	kind of binary data such as audio, video, maps, program files, computer-aided 
	design (CAD) documents and the like. The next section introduces XML and 
	explains how parties doing business can use XML tags and schemas to exchange 
	data in a meaningful way.&lt;/p&gt;
&lt;a name="bnabt"&gt;&lt;/a&gt;
&lt;h4&gt;XML&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-42"&gt;&lt;/a&gt;XML is a cross-platform, extensible, text-based 
	standard for representing data. When XML data is exchanged between parties, the 
	parties are free to create their own tags to describe the data, set up schemas 
	to specify which tags can be used in a particular kind of XML document, and use 
	XML stylesheets to manage the display and handling of the data.&lt;/p&gt;
&lt;p&gt;For example, a web service can use XML and a schema to produce price lists, and 
	companies that receive the price lists and schema can have their own 
	stylesheets to handle the data in a way that best suits their needs. Here are 
	examples:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;One company might put XML pricing information through a program to translate the 
			XML to HTML so that it can post the price lists to its intranet.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A partner company might put the XML pricing information through a tool to create 
			a marketing presentation.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Another company might read the XML pricing information into an application for 
			processing.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="bnabu"&gt;&lt;/a&gt;
&lt;h4&gt;SOAP Transport Protocol&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-43"&gt;&lt;/a&gt;Client requests and web service responses are 
	transmitted as Simple Object Access Protocol (SOAP) messages over HTTP to 
	enable a completely interoperable exchange between clients and web services, 
	all running on different platforms and at various locations on the Internet. 
	HTTP is a familiar request-and response standard for sending messages over the 
	Internet, and SOAP is an XML-based protocol that follows the HTTP 
	request-and-response model.&lt;/p&gt;
&lt;p&gt;The SOAP portion of a transported message handles the following:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Defines an XML-based envelope to describe what is in the message and how to 
			process the message&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Includes XML-based encoding rules to express instances of application-defined 
			data types within the message&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Defines an XML-based convention for representing the request to the remote 
			service and the resulting response&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="bnabv"&gt;&lt;/a&gt;
&lt;h4&gt;WSDL Standard Format&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-44"&gt;&lt;/a&gt;The Web Services Description Language (WSDL) is a 
	standardized XML format for describing network services. The description 
	includes the name of the service, the location of the service, and ways to 
	communicate with the service. WSDL service descriptions can be stored in UDDI 
	registries or published on the web (or both). The Sun Java System Application 
	Server Platform Edition 8 provides a tool for generating the WSDL specification 
	of a web service that uses remote procedure calls to communicate with clients.&lt;/p&gt;
&lt;a name="bnabw"&gt;&lt;/a&gt;
&lt;h4&gt;UDDI and ebXML Standard Formats&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-45"&gt;&lt;/a&gt;&lt;a name="indexterm-46"&gt;&lt;/a&gt;Other XML-based standards, 
	such as Universal Description, Discovery and Integration (UDDI) and ebXML, make 
	it possible for businesses to publish information on the Internet about their 
	products and web services, where the information can be readily and globally 
	accessed by clients who want to do business.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="3529601986" hide="0">
			<date>January  20, 2008</date>
			<title>Java EE Application Assembly and Deployment</title>
			<description>A Java EE application is packaged into one or more standard units for deployment to any Java EE platform-compliant system. Each unit contains:

    *

      A functional component or components (such as an enterprise bean, JSP page, servlet, or applet)
    *

      An optional deployment descriptor that describes its content

Once a Java EE unit has been produced, it is ready to be deployed. Deployment typically involves using a platform’s deployment tool to specify location-specific information, such as a list of local users that can access it and the name of the local database. Once deployed on a local platform, the application is ready to run.</description>
		</newsitem>
		<newsitem id="24004234340" hide="0">
			<date>January  20, 2008</date>
			<title>Packaging Applications</title>
			<description>&lt;p&gt;A Java EE application is delivered in an Enterprise Archive (EAR) file, a
standard Java Archive (JAR) file with an &lt;tt&gt;.ear&lt;/tt&gt; extension. Using EAR files and modules
makes it possible to assemble a number of different Java EE applications using
some of the same components. No extra coding is needed; it is
only a matter of assembling (or packaging) various Java EE modules into Java
EE EAR files.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-48"&gt;&lt;/a&gt;An EAR file (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaby.html#bnabz"&gt;Figure 1-6&lt;/a&gt;) contains Java EE modules and deployment descriptors. A &lt;b&gt;deployment descriptor&lt;/b&gt;
is an XML document with an &lt;tt&gt;.xml&lt;/tt&gt; extension that describes the deployment settings of
an application, a module, or a component. Because deployment descriptor information is declarative,
it can be changed without the need to modify the source code. At
runtime, the Java EE server reads the deployment descriptor and acts upon the
application, module, or component accordingly.&lt;/p&gt;&lt;a name="bnabz"&gt;&lt;/a&gt;&lt;h6&gt;Figure 1-6 EAR File Structure&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-applicationModule.gif" alt="Diagram of EAR file structure. META-INF and web, application client, EJB, and resource adapter modules are under the assembly root."&gt;&lt;p&gt;&lt;a name="indexterm-49"&gt;&lt;/a&gt;&lt;a name="indexterm-50"&gt;&lt;/a&gt;There are two types of deployment descriptors: Java EE and runtime. A &lt;b&gt;Java EE deployment descriptor&lt;/b&gt;
is defined by a Java EE specification and can be used to configure
deployment settings on any Java EE-compliant implementation. A &lt;b&gt;runtime deployment descriptor&lt;/b&gt; is used to configure
Java EE implementation-specific parameters. For example, the Sun Java System Application Server Platform
Edition 9 runtime deployment descriptor contains information such as the context root of
a web application, the mapping of portable names of an application’s resources to the
server’s resources, and Application Server implementation-specific parameters, such as caching directives. The Application
Server runtime deployment descriptors are named &lt;tt&gt;sun-&lt;/tt&gt;&lt;i&gt;moduleType&lt;/i&gt;&lt;tt&gt;.xml&lt;/tt&gt; and are located in the same &lt;tt&gt;META-INF&lt;/tt&gt;
directory as the Java EE deployment descriptor.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-51"&gt;&lt;/a&gt;A &lt;b&gt;Java EE module&lt;/b&gt; consists of one or more Java EE components for the
same container type and one component deployment descriptor of that type. An enterprise bean
module deployment descriptor, for example, declares transaction attributes and security authorizations for an
enterprise bean. A Java EE module without an application deployment descriptor can be
deployed as a &lt;b&gt;stand-alone&lt;/b&gt; module. &lt;/p&gt;&lt;p&gt;The four types of Java EE modules are as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-52"&gt;&lt;/a&gt;EJB modules, which contain class
files for enterprise beans and an EJB deployment descriptor. EJB
modules are packaged as JAR files with a &lt;tt&gt;.jar&lt;/tt&gt; extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-53"&gt;&lt;/a&gt;&lt;a name="indexterm-54"&gt;&lt;/a&gt;Web
modules, which contain servlet class files, JSP files, supporting class
files, GIF and HTML files, and a web application deployment descriptor.
Web modules are packaged as JAR files with a &lt;tt&gt;.war&lt;/tt&gt; (Web ARchive) extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-55"&gt;&lt;/a&gt;Application client modules, which
contain class files and an application client deployment descriptor.
Application client modules are packaged as JAR files with a &lt;tt&gt;.jar&lt;/tt&gt; extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-56"&gt;&lt;/a&gt;Resource adapter modules, which
contain all Java interfaces, classes, native libraries, and other
documentation, along with the resource adapter deployment descriptor.
Together, these implement the Connector architecture (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnacj.html#bnacz"&gt;J2EE Connector Architecture&lt;/a&gt;) for a particular EIS. Resource adapter modules are packaged as JAR files with an &lt;tt&gt;.rar&lt;/tt&gt; (resource adapter archive) extension.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</description>
		</newsitem>
		<newsitem id="32612322179" hide="0">
			<date>January  20, 2008</date>
			<title>Development Roles</title>
			<description>&lt;p&gt;Reusable modules make it possible to divide the application development and deployment process
into distinct roles so that different people or companies can perform different parts
of the process.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-59"&gt;&lt;/a&gt;The first two roles involve purchasing and installing the Java EE product and
tools. After software is purchased and installed, Java EE components can be developed
by application component providers, assembled by application assemblers, and deployed by application deployers.
In a large organization, each of these roles might be executed by different
individuals or teams. This division of labor works because each of the earlier
roles outputs a portable file that is the input for a subsequent role.
For example, in the application component development phase, an enterprise bean software developer
delivers EJB JAR files. In the application assembly role, another developer combines these EJB
JAR files into a Java EE application and saves it in an
EAR file. In the application deployment role, a system administrator at the customer site
uses the EAR file to install the Java EE application into a
Java EE server.&lt;/p&gt;&lt;p&gt;The different roles are not always executed by different people. If you work
for a small company, for example, or if you are prototyping a
sample application, you might perform the tasks in every phase.&lt;/p&gt;

&lt;a name="bnacb"&gt;&lt;/a&gt;&lt;h4&gt;Java EE Product Provider&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-60"&gt;&lt;/a&gt;The Java EE product provider is the company that designs and makes available
for purchase the Java EE platform APIs, and other features defined in the
Java EE specification. Product providers are typically application server vendors who implement the
Java EE platform according to the Java EE 5 Platform specification.&lt;/p&gt;

&lt;a name="bnacc"&gt;&lt;/a&gt;&lt;h4&gt;Tool Provider&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-61"&gt;&lt;/a&gt;The tool provider is the company or person who creates development, assembly, and
packaging tools used by component providers, assemblers, and deployers.&lt;/p&gt;

&lt;a name="bnacd"&gt;&lt;/a&gt;&lt;h4&gt;Application Component Provider&lt;/h4&gt;
&lt;p&gt;The application component provider is the company or person who creates web components,
enterprise beans, applets, or application clients for use in Java EE applications.&lt;/p&gt;

&lt;a name="bnace"&gt;&lt;/a&gt;&lt;h5&gt;Enterprise Bean Developer&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-62"&gt;&lt;/a&gt;An enterprise bean developer performs the following tasks to deliver an EJB JAR
file that contains one or more enterprise beans:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Writes and compiles the source code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specifies the deployment descriptor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packages the &lt;tt&gt;.class&lt;/tt&gt; files and deployment descriptor into the EJB JAR file&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnacf"&gt;&lt;/a&gt;&lt;h5&gt;Web Component Developer&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-63"&gt;&lt;/a&gt;A web component developer performs the following tasks to deliver a WAR file
containing one or more web components:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Writes and compiles servlet source code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writes JSP, JavaServer Faces, and HTML files&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specifies the deployment descriptor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packages the &lt;tt&gt;.class&lt;/tt&gt;, &lt;tt&gt;.jsp&lt;/tt&gt;, and&lt;tt&gt;.html&lt;/tt&gt; files and deployment descriptor into the WAR file&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnacg"&gt;&lt;/a&gt;&lt;h5&gt;Application Client Developer&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-64"&gt;&lt;/a&gt;An application client developer performs the following tasks to deliver a JAR file
containing the application client:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Writes and compiles the source code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specifies the deployment descriptor for the client&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packages the &lt;tt&gt;.class&lt;/tt&gt; files and deployment descriptor into the JAR file&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnach"&gt;&lt;/a&gt;&lt;h4&gt;Application Assembler&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-65"&gt;&lt;/a&gt;The application assembler is the company or person who receives application modules from
component providers and assembles them into a Java EE application EAR file. The
assembler or deployer can edit the deployment descriptor directly or can use tools
that correctly add XML tags according to interactive selections. &lt;/p&gt;&lt;p&gt;A software developer performs the following tasks to deliver an EAR file containing
the Java EE application:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Assembles EJB JAR and WAR files created in the previous phases into a Java EE application (EAR) file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specifies the deployment descriptor for the Java EE application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verifies that the contents of the EAR file are well formed and comply with the Java EE specification&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnaci"&gt;&lt;/a&gt;&lt;h4&gt;Application Deployer and Administrator&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-66"&gt;&lt;/a&gt;The application deployer and administrator is the company or person who configures and
deploys the Java EE application, administers the computing and networking infrastructure where Java EE
applications run, and oversees the runtime environment. Duties include such things as setting
transaction controls and security attributes and specifying connections to databases.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-67"&gt;&lt;/a&gt;During configuration, the deployer follows instructions supplied by the application component provider to resolve
external dependencies, specify security settings, and assign transaction attributes. During installation, the deployer
moves the application components to the server and generates the container-specific classes and
interfaces.&lt;/p&gt;&lt;p&gt;A deployer or system administrator performs the following tasks to install and configure
a Java EE application:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Adds the Java EE application (EAR) file created in the preceding phase to the Java EE server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configures the Java EE application for the operational
environment by modifying the deployment descriptor of the Java EE
application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verifies that the contents of the EAR file are well formed and comply with the Java EE specification&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploys (installs) the Java EE application EAR file into the Java EE server&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</description>
		</newsitem>
		<newsitem id="25146119571" hide="0">
			<date>January  20, 2008</date>
			<title>Java EE 5 APIs</title>
			<description>&lt;p&gt;&lt;a name="indexterm-68"&gt;&lt;/a&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnacj.html#bnack"&gt;Figure 
		1-7&lt;/a&gt; illustrates the availability of the Java EE 5 platform APIs in each 
	Java EE container type. The following sections give a brief summary of the 
	technologies required by the Java EE platform, and the APIs used in Java EE 
	applications.&lt;/p&gt;
&lt;a name="bnack"&gt;&lt;/a&gt;
&lt;h6&gt;Figure 1-7 Java EE Platform APIs&lt;/h6&gt;
&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/overview-j2eeArchitecture.gif"
	alt="Diagram of Java EE Platform APIs for the applet, web, EJB, and application client containers."&gt;
&lt;a name="bnacl"&gt;&lt;/a&gt;
&lt;h4&gt;Enterprise JavaBeans Technology&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-69"&gt;&lt;/a&gt;An Enterprise JavaBeans&lt;sup&gt;TM&lt;/sup&gt; (EJB) component, 
	or &lt;b&gt;enterprise bean&lt;/b&gt;, is a body of code having fields and methods to 
	implement modules of business logic. You can think of an enterprise bean as a 
	building block that can be used alone or with other enterprise beans to execute 
	business logic on the Java EE server.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-70"&gt;&lt;/a&gt;&lt;a name="indexterm-71"&gt;&lt;/a&gt;There are two kinds of 
	enterprise beans: session beans and message-driven beans. A &lt;b&gt;session bean&lt;/b&gt; 
	represents a transient conversation with a client. When the client finishes 
	executing, the session bean and its data are gone. A &lt;b&gt;message-driven bean&lt;/b&gt; 
	combines features of a session bean and a message listener, allowing a business 
	component to receive messages asynchronously. Commonly, these are Java Message 
	Service (JMS) messages.&lt;/p&gt;
&lt;p&gt;In Java EE 5, entity beans have been replaced by Java persistence API entities. 
	An entity represents persistent data stored in one row of a database table. If 
	the client terminates, or if the server shuts down, the persistence manager 
	ensures that the entity data is saved.&lt;/p&gt;
&lt;a name="bnacm"&gt;&lt;/a&gt;
&lt;h4&gt;Java Servlet Technology&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-72"&gt;&lt;/a&gt;&lt;a name="indexterm-73"&gt;&lt;/a&gt;Java servlet technology 
	lets you define HTTP-specific servlet classes. A servlet class extends the 
	capabilities of servers that host applications that are accessed by way of a 
	request-response programming model. Although servlets can respond to any type 
	of request, they are commonly used to extend the applications hosted by web 
	servers.&lt;/p&gt;
&lt;a name="bnacn"&gt;&lt;/a&gt;
&lt;h4&gt;JavaServer Pages Technology&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-74"&gt;&lt;/a&gt;&lt;a name="indexterm-75"&gt;&lt;/a&gt;JavaServer Pages&lt;sup&gt;TM&lt;/sup&gt;
	(JSP) technology lets you put snippets of servlet code directly into a 
	text-based document. A JSP page is a text-based document that contains two 
	types of text: static data (which can be expressed in any text-based format 
	such as HTML, WML, and XML) and JSP elements, which determine how the page 
	constructs dynamic content.&lt;/p&gt;
&lt;a name="bnaco"&gt;&lt;/a&gt;
&lt;h4&gt;JavaServer Pages Standard Tag Library&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-76"&gt;&lt;/a&gt;&lt;a name="indexterm-77"&gt;&lt;/a&gt;The JavaServer Pages 
	Standard Tag Library (JSTL) encapsulates core functionality common to many JSP 
	applications. Instead of mixing tags from numerous vendors in your JSP 
	applications, you employ a single, standard set of tags. This standardization 
	allows you to deploy your applications on any JSP container that supports JSTL 
	and makes it more likely that the implementation of the tags is optimized.&lt;/p&gt;
&lt;p&gt;JSTL has iterator and conditional tags for handling flow control, tags for 
	manipulating XML documents, internationalization tags, tags for accessing 
	databases using SQL, and commonly used functions.&lt;/p&gt;
&lt;a name="bnacp"&gt;&lt;/a&gt;
&lt;h4&gt;JavaServer Faces&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-78"&gt;&lt;/a&gt;JavaServer Faces technology is a user interface 
	framework for building web applications. The main components of JavaServer 
	Faces technology are as follows:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;A GUI component framework.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A flexible model for rendering components in different kinds of HTML or 
			different markup languages and technologies. A &lt;tt&gt;Renderer&lt;/tt&gt; object 
			generates the markup to render the component and converts the data stored in a 
			model object to types that can be represented in a view.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A standard &lt;tt&gt;RenderKit&lt;/tt&gt; for generating HTML/4.01 markup.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following features support the GUI components:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Input validation&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Event handling&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Data conversion between model objects and components&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Managed model object creation&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Page navigation configuration&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All this functionality is available using standard Java APIs and XML-based 
	configuration files.&lt;/p&gt;
&lt;a name="bnacq"&gt;&lt;/a&gt;
&lt;h4&gt;Java Message Service API&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-79"&gt;&lt;/a&gt;The Java Message Service (JMS) API is a messaging 
	standard that allows Java EE application components to create, send, receive, 
	and read messages. It enables distributed communication that is loosely 
	coupled, reliable, and asynchronous.&lt;/p&gt;
&lt;a name="bnacr"&gt;&lt;/a&gt;
&lt;h4&gt;Java Transaction API&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-80"&gt;&lt;/a&gt;&lt;a name="indexterm-81"&gt;&lt;/a&gt;The Java Transaction API 
	(JTA) provides a standard interface for demarcating transactions. The Java EE 
	architecture provides a default auto commit to handle transaction commits and 
	rollbacks. An &lt;b&gt;auto commit&lt;/b&gt; means that any other applications that are 
	viewing data will see the updated data after each database read or write 
	operation. However, if your application performs two separate database access 
	operations that depend on each other, you will want to use the JTA API to 
	demarcate where the entire transaction, including both operations, begins, 
	rolls back, and commits.&lt;/p&gt;
&lt;a name="bnacs"&gt;&lt;/a&gt;
&lt;h4&gt;JavaMail API&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-82"&gt;&lt;/a&gt;Java EE applications use the JavaMail&lt;sup&gt;TM&lt;/sup&gt; API 
	to send email notifications. The JavaMail API has two parts: an 
	application-level interface used by the application components to send mail, 
	and a service provider interface. The Java EE platform includes JavaMail with a 
	service provider that allows application components to send Internet mail.&lt;/p&gt;
&lt;a name="bnact"&gt;&lt;/a&gt;
&lt;h4&gt;JavaBeans Activation Framework&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-83"&gt;&lt;/a&gt;&lt;a name="indexterm-84"&gt;&lt;/a&gt;The JavaBeans Activation 
	Framework (JAF) is included because JavaMail uses it. JAF provides standard 
	services to determine the type of an arbitrary piece of data, encapsulate 
	access to it, discover the operations available on it, and create the 
	appropriate JavaBeans component to perform those operations.&lt;/p&gt;
&lt;a name="bnacu"&gt;&lt;/a&gt;
&lt;h4&gt;Java API for XML Processing&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-85"&gt;&lt;/a&gt;&lt;a name="indexterm-86"&gt;&lt;/a&gt;The Java API for XML 
	Processing (JAXP), part of the Java SE platform, supports the processing of XML 
	documents using Document Object Model (DOM), Simple API for XML (SAX), and 
	Extensible Stylesheet Language Transformations (XSLT). JAXP enables 
	applications to parse and transform XML documents independent of a particular 
	XML processing implementation.&lt;/p&gt;
&lt;p&gt;JAXP also provides namespace support, which lets you work with schemas that 
	might otherwise have naming conflicts. Designed to be flexible, JAXP lets you 
	use any XML-compliant parser or XSL processor from within your application and 
	supports the W3C schema. You can find information on the W3C schema at this 
	URL: &lt;a href="http://www.w3.org/XML/Schema"&gt;http://www.w3.org/XML/Schema&lt;/a&gt;.&lt;/p&gt;
&lt;a name="bnacv"&gt;&lt;/a&gt;
&lt;h4&gt;Java API for XML Web Services (JAX-WS)&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-87"&gt;&lt;/a&gt;&lt;a name="indexterm-88"&gt;&lt;/a&gt;The JAX-WS specification 
	provides support for web services that use the JAXB API for binding XML data to 
	Java objects. The JAX-WS specification defines client APIs for accessing web 
	services as well as techniques for implementing web service endpoints. The Web 
	Services for J2EE specification describes the deployment of JAX-WS-based 
	services and clients. The EJB and servlet specifications also describe aspects 
	of such deployment. It must be possible to deploy JAX-WS-based applications 
	using any of these deployment models.&lt;/p&gt;
&lt;p&gt;The JAX-WS specification describes the support for message handlers that can 
	process message requests and responses. In general, these message handlers 
	execute in the same container and with the same privileges and execution 
	context as the JAX-WS client or endpoint component with which they are 
	associated. These message handlers have access to the same JNDI &lt;tt&gt;java:comp/env&lt;/tt&gt;
	namespace as their associated component. Custom serializers and deserializers, 
	if supported, are treated in the same way as message handlers.&lt;/p&gt;
&lt;a name="bnacw"&gt;&lt;/a&gt;
&lt;h4&gt;Java Architecture for XML Binding (JAXB)&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-89"&gt;&lt;/a&gt;&lt;a name="indexterm-90"&gt;&lt;/a&gt;The Java Architecture for 
	XML Binding (JAXB) provides a convenient way to bind an XML schema to a 
	representation in Java language programs. JAXB can be used independently or in 
	combination with JAX-WS, where it provides a standard data binding for web 
	service messages. All Java EE application client containers, web containers, 
	and EJB containers support the JAXB API.&lt;/p&gt;
&lt;a name="bnacx"&gt;&lt;/a&gt;
&lt;h4&gt;SOAP with Attachments API for Java&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-91"&gt;&lt;/a&gt;&lt;a name="indexterm-92"&gt;&lt;/a&gt;The SOAP with Attachments 
	API for Java (SAAJ) is a low-level API on which JAX-WS and JAXR depend. SAAJ 
	enables the production and consumption of messages that conform to the SOAP 1.1 
	specification and SOAP with Attachments note. Most developers do not use the 
	SAAJ API, instead using the higher-level JAX-WS API.&lt;/p&gt;
&lt;a name="bnacy"&gt;&lt;/a&gt;
&lt;h4&gt;Java API for XML Registries&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-93"&gt;&lt;/a&gt;&lt;a name="indexterm-94"&gt;&lt;/a&gt;&lt;a name="indexterm-95"&gt;&lt;/a&gt;&lt;a name="indexterm-96"&gt;&lt;/a&gt;The 
	Java API for XML Registries (JAXR) lets you access business and general-purpose 
	registries over the web. JAXR supports the ebXML Registry and Repository 
	standards and the emerging UDDI specifications. By using JAXR, developers can 
	learn a single API and gain access to both of these important registry 
	technologies.&lt;/p&gt;
&lt;p&gt;Additionally, businesses can submit material to be shared and search for 
	material that others have submitted. Standards groups have developed schemas 
	for particular kinds of XML documents; two businesses might, for example, agree 
	to use the schema for their industry’s standard purchase order form. Because 
	the schema is stored in a standard business registry, both parties can use JAXR 
	to access it.&lt;/p&gt;
&lt;a name="bnacz"&gt;&lt;/a&gt;
&lt;h4&gt;J2EE Connector Architecture&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-97"&gt;&lt;/a&gt;&lt;a name="indexterm-98"&gt;&lt;/a&gt;&lt;a name="indexterm-99"&gt;&lt;/a&gt;The 
	J2EE Connector architecture is used by tools vendors and system integrators to 
	create resource adapters that support access to enterprise information systems 
	that can be plugged in to any Java EE product. A &lt;b&gt;resource adapter&lt;/b&gt; is a 
	software component that allows Java EE application components to access and 
	interact with the underlying resource manager of the EIS. Because a resource 
	adapter is specific to its resource manager, typically there is a different 
	resource adapter for each type of database or enterprise information system.&lt;/p&gt;
&lt;p&gt;The J2EE Connector architecture also provides a performance-oriented, secure, 
	scalable, and message-based transactional integration of Java EE-based web 
	services with existing EISs that can be either synchronous or asynchronous. 
	Existing applications and EISs integrated through the J2EE Connector 
	architecture into the Java EE platform can be exposed as XML-based web services 
	by using JAX-WS and Java EE component models. Thus JAX-WS and the J2EE 
	Connector architecture are complementary technologies for enterprise 
	application integration (EAI) and end-to-end business integration.&lt;/p&gt;
&lt;a name="bnada"&gt;&lt;/a&gt;
&lt;h4&gt;Java Database Connectivity API&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-100"&gt;&lt;/a&gt;&lt;a name="indexterm-101"&gt;&lt;/a&gt;The Java Database 
	Connectivity (JDBC) API lets you invoke SQL commands from Java programming 
	language methods. You use the JDBC API in an enterprise bean when you have a 
	session bean access the database. You can also use the JDBC API from a servlet 
	or a JSP page to access the database directly without going through an 
	enterprise bean.&lt;/p&gt;
&lt;p&gt;The JDBC API has two parts: an application-level interface used by the 
	application components to access a database, and a service provider interface 
	to attach a JDBC driver to the Java EE platform.&lt;/p&gt;
&lt;a name="bnadb"&gt;&lt;/a&gt;
&lt;h4&gt;Java Persistence API&lt;/h4&gt;
&lt;p&gt;The Java Persistence API is a Java standards-based solution for persistence. 
	Persistence uses an object-relational mapping approach to bridge the gap 
	between an object oriented model and a relational database. Java Persistence 
	consists of three areas:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;The Java Persistence API&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;The query language&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Object/relational mapping metadata&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="bnadc"&gt;&lt;/a&gt;
&lt;h4&gt;Java Naming and Directory Interface&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-102"&gt;&lt;/a&gt;&lt;a name="indexterm-103"&gt;&lt;/a&gt;&lt;a name="indexterm-104"&gt;&lt;/a&gt;&lt;a name="indexterm-105"&gt;&lt;/a&gt;&lt;a name="indexterm-106"&gt;&lt;/a&gt;&lt;a name="indexterm-107"&gt;&lt;/a&gt;&lt;a name="indexterm-108"&gt;&lt;/a&gt;The 
	Java Naming and Directory Interface&lt;sup&gt;TM&lt;/sup&gt; (JNDI) provides naming and 
	directory functionality, enabling applications to access multiple naming and 
	directory services, including existing naming and directory services such as 
	LDAP, NDS, DNS, and NIS. It provides applications with methods for performing 
	standard directory operations, such as associating attributes with objects and 
	searching for objects using their attributes. Using JNDI, a Java EE application 
	can store and retrieve any type of named Java object, allowing Java EE 
	applications to coexist with many legacy applications and systems.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-109"&gt;&lt;/a&gt;&lt;a name="indexterm-110"&gt;&lt;/a&gt;Java EE naming services 
	provide application clients, enterprise beans, and web components with access 
	to a JNDI naming environment. A &lt;b&gt;naming environment&lt;/b&gt; allows a component to 
	be customized without the need to access or change the component’s source code. 
	A container implements the component’s environment and provides it to the 
	component as a JNDI &lt;b&gt;naming context&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-111"&gt;&lt;/a&gt;&lt;a name="indexterm-112"&gt;&lt;/a&gt;A Java EE component can 
	locate its environment naming context using JNDI interfaces. A component can 
	create a &lt;tt&gt;javax.naming.InitialContext&lt;/tt&gt; object and looks up the 
	environment naming context in &lt;tt&gt;InitialContext&lt;/tt&gt; under the name &lt;tt&gt;java:comp/env&lt;/tt&gt;. 
	A component’s naming environment is stored directly in the environment naming 
	context or in any of its direct or indirect subcontexts.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-113"&gt;&lt;/a&gt;&lt;a name="indexterm-114"&gt;&lt;/a&gt;&lt;a name="indexterm-115"&gt;&lt;/a&gt;A 
	Java EE component can access named system-provided and user-defined objects. 
	The names of system-provided objects, such as JTA &lt;tt&gt;UserTransaction&lt;/tt&gt; objects, 
	are stored in the environment naming context, &lt;tt&gt;java:comp/en&lt;/tt&gt;v. The Java 
	EE platform allows a component to name user-defined objects, such as enterprise 
	beans, environment entries, JDBC &lt;tt&gt;DataSource&lt;/tt&gt; objects, and message 
	connections. An object should be named within a subcontext of the naming 
	environment according to the type of the object. For example, enterprise beans 
	are named within the subcontext &lt;tt&gt;java:comp/env/ejb&lt;/tt&gt;, and JDBC &lt;tt&gt;DataSource&lt;/tt&gt;
	references in the subcontext &lt;tt&gt;java:comp/env/jdbc&lt;/tt&gt;.&lt;/p&gt;
&lt;a name="bnadd"&gt;&lt;/a&gt;
&lt;h4&gt;Java Authentication and Authorization Service&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-116"&gt;&lt;/a&gt;&lt;a name="indexterm-117"&gt;&lt;/a&gt;The Java Authentication 
	and Authorization Service (JAAS) provides a way for a Java EE application to 
	authenticate and authorize a specific user or group of users to run it.&lt;/p&gt;
&lt;p&gt;JAAS is a Java programming language version of the standard Pluggable 
	Authentication Module (PAM) framework, which extends the Java Platform security 
	architecture to support user-based authorization.&lt;/p&gt;
&lt;a name="bnade"&gt;&lt;/a&gt;
&lt;h4&gt;Simplified Systems Integration&lt;/h4&gt;
&lt;p&gt;The Java EE platform is a platform-independent, full systems integration 
	solution that creates an open marketplace in which every vendor can sell to 
	every customer. Such a marketplace encourages vendors to compete, not by trying 
	to lock customers into their technologies but instead by trying to outdo each 
	other in providing products and services that benefit customers, such as better 
	performance, better tools, or better customer support.&lt;/p&gt;
&lt;p&gt;The Java EE 5 APIs enable systems and applications integration through the 
	following:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Unified application model across tiers with enterprise beans&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Simplified request-and-response mechanism with JSP pages and servlets&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Reliable security model with JAAS&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;XML-based data interchange integration with JAXP, SAAJ, and JAX-WS&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Simplified interoperability with the J2EE Connector architecture&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Easy database connectivity with the JDBC API&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enterprise application integration with message-driven beans and JMS, JTA, and 
			JNDI&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;</description>
		</newsitem>
		<newsitem id="23982087786" hide="0">
			<date>January  20, 2008</date>
			<title>Sun Java System Application Server Platform Edition 9</title>
			<description>&lt;p&gt;The Sun Java System Application Server Platform Edition 9 is a fully compliant 
	implementation of the Java EE 5 platform. In addition to supporting all the 
	APIs described in the previous sections, the Application Server includes a 
	number of Java EE tools that are not part of the Java EE 5 platform but are 
	provided as a convenience to the developer.&lt;/p&gt;
&lt;p&gt;This section briefly summarizes the tools that make up the Application Server. 
	Instructions for starting and stopping the Application Server, starting the 
	Admin Console, and starting and stopping the Java DB database server are in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/gfiud.html"&gt;
		Chapter 2, Using the Tutorial Examples&lt;/a&gt;.&lt;/p&gt;
&lt;a name="bnadg"&gt;&lt;/a&gt;
&lt;h4&gt;Tools&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-120"&gt;&lt;/a&gt;The Application Server contains the tools listed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadf.html#bnadh"&gt;
		Table 1-1&lt;/a&gt;. Basic usage information for many of the tools appears 
	throughout the tutorial. For detailed information, see the online help in the 
	GUI tools.&lt;/p&gt;
&lt;a name="bnadh"&gt;&lt;/a&gt;
&lt;h6&gt;Table 1-1 Application Server Tools&lt;/h6&gt;
&lt;table ID="Table1"&gt;
	&lt;col width="95*"&gt;
	&lt;col width="260*"&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;th align="left" valign="top"&gt;
				&lt;p&gt;Tool&lt;/p&gt;
			&lt;/th&gt;
			&lt;th align="left" valign="top"&gt;
				&lt;p&gt;Description&lt;/p&gt;
			&lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-121"&gt;&lt;/a&gt;Admin Console&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A web-based GUI Application Server administration 
					utility. Used to stop the Application Server and manage users, resources, and 
					applications.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-122"&gt;&lt;/a&gt;&lt;tt&gt;asadmin&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line Application Serveradministration 
					utility. Used to start and stop the Application Server and manage users, 
					resources, and applications.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-123"&gt;&lt;/a&gt;&lt;tt&gt;asant&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A portable command-line build tool that is an 
					extension of the Ant tool developed by the Apache Software Foundation (see &lt;a href="http://ant.apache.org/"&gt;
						http://ant.apache.org/&lt;/a&gt;). &lt;tt&gt;asant&lt;/tt&gt; contains additional tasks that 
					interact with the Application Server administration utility.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-124"&gt;&lt;/a&gt;&lt;tt&gt;appclient&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool that launches the application 
					client container and invokes the client application packaged in the application 
					client JAR file.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-125"&gt;&lt;/a&gt;&lt;tt&gt;capture-schema&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to extract schema information from 
					a database, producing a schema file that the Application Server can use for 
					container-managed persistence.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-126"&gt;&lt;/a&gt;&lt;tt&gt;package-appclient&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to package the application client 
					container libraries and JAR files.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-127"&gt;&lt;/a&gt;Java DB database&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A copy of the Java DB database server.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-128"&gt;&lt;/a&gt;&lt;tt&gt;verifier&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to validate Java EE deployment 
					descriptors.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-129"&gt;&lt;/a&gt;&lt;tt&gt;xjc&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to transform, or bind, a source 
					XML schema to a set of JAXB content classes in the Java programming language.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-130"&gt;&lt;/a&gt;&lt;tt&gt;schemagen&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to create a schema file for each 
					namespace referenced in your Java classes.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-131"&gt;&lt;/a&gt;&lt;tt&gt;wsimport&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to generate JAX-WS portable 
					artifacts for a given WSDL file. After generation, these artifacts can be 
					packaged in a WAR file with the WSDL and schema documents along with the 
					endpoint implementation and then deployed.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a name="indexterm-132"&gt;&lt;/a&gt;&lt;tt&gt;wsgen&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;A command-line tool to read a web service endpoint 
					class and generate all the required JAX-WS portable artifacts for web service 
					deployment and invocation.&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;</description>
		</newsitem>
		<newsitem id="3254898943" hide="0">
			<date>January  20, 2008</date>
			<title>Getting Started with Web Applications</title>
			<description>&lt;p&gt;A web application is a dynamic extension of a web or application
server. There are two types of web applications:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-163"&gt;&lt;/a&gt;&lt;b&gt;Presentation-oriented&lt;/b&gt;: A
presentation-oriented web application generates interactive web pages
containing various types of markup language (HTML, XML, and so on) and
dynamic content in response to requests. Chapters &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt; through &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaxu.html"&gt;Chapter 15, Internationalizing and Localizing Web Applications&lt;/a&gt; cover how to develop presentation-oriented web applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-164"&gt;&lt;/a&gt;&lt;b&gt;Service-oriented&lt;/b&gt;: A
service-oriented web application implements the endpoint of a web
service. Presentation-oriented applications are often clients of
service-oriented web applications. Chapters &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnayl.html"&gt;Chapter 16, Building Web Services with JAX-WS&lt;/a&gt; and &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbhf.html"&gt;Chapter 19, SOAP with Attachments API for Java&lt;/a&gt; cover how to develop service-oriented web applications.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</description>
		</newsitem>
		<newsitem id="40885547928" hide="0">
			<date>January  20, 2008</date>
			<title>Web Applications</title>
			<description>&lt;p&gt;In the Java 2 platform, &lt;b&gt;web components&lt;/b&gt; provide the dynamic extension capabilities for a web
server. Web components are either Java servlets, JSP pages, or web service endpoints.
The interaction between a web client and a web application is illustrated in
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/geysj.html#bnads"&gt;Figure 3-1&lt;/a&gt;. The client sends an HTTP request to the web server. A web
server that implements Java Servlet and JavaServer Pages technology converts the request into
an &lt;tt&gt;HTTPServletRequest&lt;/tt&gt; object. This object is delivered to a web component, which can
interact with JavaBeans components or a database to generate dynamic content. The web
component can then generate an &lt;tt&gt;HTTPServletResponse&lt;/tt&gt; or it can pass the request to
another web component. Eventually a web component generates a &lt;tt&gt;HTTPServletResponse&lt;/tt&gt; object. The web
server converts this object to an HTTP response and returns it to the
client.&lt;/p&gt;&lt;a name="bnads"&gt;&lt;/a&gt;&lt;h6&gt;Figure 3-1 Java Web Application Request Handling&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-requestHandling.gif" alt="Diagram of web application request handling. Clients and web components communicate using HttpServletRequest and HttpServletResponse."&gt;&lt;p&gt;&lt;b&gt;Servlets&lt;/b&gt; are Java programming language classes that dynamically process requests and construct responses.
&lt;b&gt;JSP pages&lt;/b&gt; are text-based documents that execute as servlets but allow a more natural
approach to creating static content. Although servlets and JSP pages can be used
interchangeably, each has its own strengths. Servlets are best suited for service-oriented applications (web
service endpoints are implemented as servlets) and the control functions of a presentation-oriented
application, such as dispatching requests and handling nontextual data. JSP pages are more
appropriate for generating text-based markup such as HTML, Scalable Vector Graphics (SVG), Wireless
Markup Language (WML), and XML.&lt;/p&gt;&lt;p&gt;Since the introduction of Java Servlet and JSP technology, additional Java technologies and
frameworks for building interactive web applications have been developed. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/geysj.html#bnadt"&gt;Figure 3-2&lt;/a&gt; illustrates these technologies and
their relationships.&lt;/p&gt;&lt;a name="bnadt"&gt;&lt;/a&gt;&lt;h6&gt;Figure 3-2 Java Web Application Technologies&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-technologies.gif" alt="Diagram of web application technologies. JavaServer Pages, the JSP Standard Tag Library, and JavaServer Faces rest on JavaServlet technology."&gt;&lt;p&gt;Notice that Java Servlet technology is the foundation of all the web application
technologies, so you should familiarize yourself with the material in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt; even if you
do not intend to write servlets. Each technology adds a level of
abstraction that makes web application prototyping and development faster and the web applications themselves
more maintainable, scalable, and robust.&lt;/p&gt;&lt;p&gt;Web components are supported by the services of a runtime platform called a
&lt;b&gt;web container&lt;/b&gt;. A web container provides services such as request dispatching, security, concurrency, and
life-cycle management. It also gives web components access to APIs such as naming,
transactions, and email.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-167"&gt;&lt;/a&gt;&lt;a name="indexterm-168"&gt;&lt;/a&gt;Certain aspects of web application behavior can be configured when the application is
installed, or &lt;b&gt;deployed&lt;/b&gt;, to the web container. The configuration information is maintained in
a text file in XML format called a &lt;b&gt;web application deployment descriptor&lt;/b&gt; (DD). A DD must conform
to the schema described in the &lt;a href="http://java.sun.com/products/servlet/download.html#specs"&gt;Java Servlet Specification&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;This chapter gives a brief overview of the activities involved in developing web
applications. First it summarizes the web application life cycle. Then it describes how
to package and deploy very simple web applications on the Application Server. It
moves on to configuring web applications and discusses how to specify the most
commonly used configuration parameters. It then introduces an example, Duke’s Bookstore, which illustrates
all the Java EE web-tier technologies, and describes how to set up the
shared components of this example. Finally it discusses how to access databases from
web applications and set up the database resources needed to run Duke’s Bookstore.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="24948599294" hide="0">
			<date>January  20, 2008</date>
			<title>Web Application Life Cycle</title>
			<description>A web application consists of web components, static resource files such as images, and helper classes and libraries. The web container provides many supporting services that enhance the capabilities of web components and make them easier to develop. However, because a web application must take these services into account, the process for creating and running a web application is different from that of traditional stand-alone Java classes.

The process for creating, deploying, and executing a web application can be summarized as follows:

   1.

      Develop the web component code.
   2.

      Develop the web application deployment descriptor.
   3.

      Compile the web application components and helper classes referenced by the components.
   4.

      Optionally package the application into a deployable unit.
   5.

      Deploy the application into a web container.
   6.

      Access a URL that references the web application.

Developing web component code is covered in the later chapters. Steps 2 through 4 are expanded on in the following sections and illustrated with a Hello, World-style presentation-oriented application. This application allows a user to enter a name into an HTML form (Figure 3-3) and then displays a greeting after the name is submitted (Figure 3-4).
Figure 3-3 Greeting Form
Screen capture of Duke&amp;#8216;s greeting,
Figure 3-4 Response
Screen capture of Duke&amp;#8216;s response,

The Hello application contains two web components that generate the greeting and the response. This chapter discusses two versions of the application: a JSP version called hello1, in which the components are implemented by two JSP pages (tut-install/javaeetutorial5/examples/web/hello1/web/index.jsp and tut-install/javaeetutorial5/examples/web/hello1/web/response.jsp) and a servlet version called hello2, in which the components are implemented by two servlet classes (tut-install/javaeetutorial5/examples/web/hello2/src/servlets/GreetingServlet.java and tut-install/javaeetutorial5/examples/web/hello2/src/servlets/ResponseServlet.java). The two versions are used to illustrate tasks involved in packaging, deploying, configuring, and running an application that contains web components. The section Chapter 2, Using the Tutorial Examples explains how to get the code for these examples.

After you install the tutorial bundle, the source code for the examples is in the following directories:

    *

      tut-install/javaeetutorial5/examples/web/hello1/
    *

      tut-install/javaeetutorial5/examples/web/hello2/</description>
		</newsitem>
		<newsitem id="18077580542" hide="0">
			<date>January  20, 2008</date>
			<title>Web Modules</title>
			<description>&lt;p&gt;In the Java EE architecture, web components and static web content files such
as images are called &lt;b&gt;web resources&lt;/b&gt;. A &lt;b&gt;web module&lt;/b&gt; is the smallest deployable and
usable unit of web resources. A Java EE web module corresponds to a
&lt;b&gt;web application&lt;/b&gt; as defined in the Java Servlet specification.&lt;/p&gt;&lt;p&gt;In addition to web components and web resources, a web module can
contain other files:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-176"&gt;&lt;/a&gt;&lt;a name="indexterm-177"&gt;&lt;/a&gt;Server-side
utility classes (database beans, shopping carts, and so on). Often
these classes conform to the JavaBeans component architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client-side classes (applets and utility classes).&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;A web module has a specific structure. The top-level directory of a web
module is the &lt;b&gt;document root&lt;/b&gt; of the application. The document root is where JSP
pages, &lt;b&gt;client-side&lt;/b&gt; classes and archives, and static web resources, such as images, are
stored.&lt;/p&gt;&lt;p&gt;The document root contains a subdirectory named &lt;tt&gt;WEB-INF&lt;/tt&gt;, which contains the following files
and directories:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-178"&gt;&lt;/a&gt;&lt;tt&gt;web.xml&lt;/tt&gt;: The web application deployment descriptor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tag library descriptor files (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnamu.html"&gt;Tag Library Descriptors&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;classes&lt;/tt&gt;: A directory that contains &lt;b&gt;server-side classes&lt;/b&gt;: servlets, utility classes, and JavaBeans components&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;tags&lt;/tt&gt;: A directory that contains tag files, which are implementations of tag libraries (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html#bnamb"&gt;Tag File Location&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;lib&lt;/tt&gt;: A directory that contains JAR archives of libraries called by server-side classes&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;If your web module does not contain any servlets, filter, or listener components
then it does not need a web application deployment descriptor. In other words,
if your web module only contains JSP pages and static files then you
are not required to include a &lt;tt&gt;web.xml&lt;/tt&gt; file. The &lt;tt&gt;hello1&lt;/tt&gt; example, first discussed
in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadx.html#bnadz"&gt;Packaging Web Modules&lt;/a&gt;, contains only JSP pages and images and therefore does not include
a deployment descriptor.&lt;/p&gt;&lt;p&gt;You can also create application-specific subdirectories (that is, package directories) in either the
document root or the &lt;tt&gt;WEB-INF/classes/&lt;/tt&gt; directory.&lt;/p&gt;&lt;p&gt;A web module can be deployed as an unpacked file structure or
can be packaged in a JAR file known as a web archive (WAR)
file. Because the contents and use of WAR files differ from those of
JAR files, WAR file names use a &lt;tt&gt;.war&lt;/tt&gt; extension. The web module
just described is portable; you can deploy it into any web container that
conforms to the Java Servlet Specification.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-179"&gt;&lt;/a&gt;To deploy a WAR on the Application Server, the file must also contain
a runtime deployment descriptor. The runtime deployment descriptor is an XML file that
contains information such as the context root of the web application and the
mapping of the portable names of an application’s resources to the Application Server’s resources.
The Application Server web application runtime DD is named &lt;tt&gt;sun-web.xml&lt;/tt&gt; and is
located in the &lt;tt&gt;WEB-INF&lt;/tt&gt; directory along with the web application DD. The structure
of a web module that can be deployed on the Application Server is
shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadx.html#bnady"&gt;Figure 3-5&lt;/a&gt;.&lt;/p&gt;&lt;a name="bnady"&gt;&lt;/a&gt;&lt;h6&gt;Figure 3-5 Web Module Structure&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-module.gif" alt="Diagram of web module structure. WEB-INF and web pages are under the root. Under WEB-INF are descriptors and the lib, classes, and tags directories."&gt;

&lt;a name="bnadz"&gt;&lt;/a&gt;&lt;h4&gt;Packaging Web Modules&lt;/h4&gt;
&lt;p&gt;A web module must be packaged into a WAR in certain deployment
scenarios and whenever you want to distribute the web module. You package a
web module into a WAR by executing the &lt;tt&gt;jar&lt;/tt&gt; command in a directory laid
out in the format of a web module, by using the Ant
utility, or by using the IDE tool of your choice. This tutorial shows
you how to use NetBeans IDE or Ant to build, package, and deploy
the sample applications.&lt;/p&gt;&lt;p&gt;To build the &lt;tt&gt;hello1&lt;/tt&gt; application with NetBeans IDE, follow these instructions:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;hello1&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;hello1&lt;/tt&gt; project and select Build Project.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To build the &lt;tt&gt;hello1&lt;/tt&gt; application using the Ant utility, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello1/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This command will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello1/build/&lt;/tt&gt; directory, create the WAR file, and copy it to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello1/dist/&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnaea"&gt;&lt;/a&gt;&lt;h4&gt;Deploying a WAR File&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-180"&gt;&lt;/a&gt;You can deploy a WAR file to the Application Server in a
few ways:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Copying the WAR into the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;domain-dir&lt;/i&gt;&lt;tt&gt;/autodeploy/&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using the Admin Console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By running &lt;tt&gt;asadmin&lt;/tt&gt; or &lt;tt&gt;ant&lt;/tt&gt; to deploy the WAR.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using NetBeans IDE.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;All these methods are described briefly in this chapter; however, throughout the tutorial,
you will use &lt;tt&gt;ant&lt;/tt&gt; and NetBeans IDE for packaging and deploying.&lt;/p&gt;

&lt;a name="bnaeb"&gt;&lt;/a&gt;&lt;h5&gt;Setting the Context Root&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-181"&gt;&lt;/a&gt;A &lt;b&gt;context root&lt;/b&gt; identifies a web application in a Java EE server. You
specify the context root when you deploy a web module. A context root
must start with a forward slash (&lt;tt&gt;/&lt;/tt&gt;) and end with a string.&lt;/p&gt;&lt;p&gt;In a packaged web module for deployment on the Application Server, the context
root is stored in &lt;tt&gt;sun-web.xml&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;To edit the context root, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand your project tree in the Projects pane of NetBeans IDE.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Web Pages and WEB-INF nodes of your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click &lt;tt&gt;sun-web.xml&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the editor pane, click Edit As XML.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Edit the context root, which is enclosed by the &lt;tt&gt;context-root&lt;/tt&gt; element.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnaec"&gt;&lt;/a&gt;&lt;h5&gt;Deploying a Packaged Web Module&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-182"&gt;&lt;/a&gt;If you have deployed the &lt;tt&gt;hello1&lt;/tt&gt; application, before proceeding with this section,
undeploy the application by following one of the procedures described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadx.html#bnaen"&gt;Undeploying Web Modules&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnaed"&gt;&lt;/a&gt;&lt;h5&gt;Deploying with the Admin Console&lt;/h5&gt;

&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the Applications node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Web Applications node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Deploy button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the radio button labeled “Package file to be uploaded to the Application Server.”&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the full path to the WAR file (or click on Browse to find it), and then click the OK button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Next.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the application name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the context root.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Enabled box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Finish button.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnaee"&gt;&lt;/a&gt;&lt;h5&gt;Deploying with &lt;tt&gt;asadmin&lt;/tt&gt;&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-183"&gt;&lt;/a&gt;To deploy a WAR with &lt;tt&gt;asadmin&lt;/tt&gt;, open a terminal window or command prompt
and execute&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;asadmin deploy &lt;/b&gt;&lt;/tt&gt;&lt;b&gt;&lt;i&gt;full-path-to-war-file&lt;/i&gt;&lt;tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;

&lt;a name="bnaef"&gt;&lt;/a&gt;&lt;h5&gt;Deploying with Ant&lt;/h5&gt;
&lt;p&gt;To deploy a WAR with the Ant tool, open a terminal window
or command prompt in the directory where you built and packaged the WAR,
and execute&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;&lt;/pre&gt;

&lt;a name="bnaeg"&gt;&lt;/a&gt;&lt;h5&gt;Deploying with NetBeans IDE&lt;/h5&gt;
&lt;p&gt;To deploy a WAR with NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to your project and open it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the project and select Deploy Project.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnaeh"&gt;&lt;/a&gt;&lt;h4&gt;Testing Deployed Web Modules&lt;/h4&gt;
&lt;p&gt;Now that the web module is deployed, you can view it by
opening the application in a web browser. By default, the application is deployed
to host &lt;tt&gt;localhost&lt;/tt&gt; on port 8080. The context root of the web
application is &lt;tt&gt;hello1&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;To test the application, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Open a web browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the following URL in the web address box:&lt;/p&gt;&lt;pre&gt;http://localhost:8080/hello1&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your name, and click Submit.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The application should display the name you submitted as shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadu.html#bnadv"&gt;Figure 3-3&lt;/a&gt;
and &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadu.html#bnadw"&gt;Figure 3-4&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnaei"&gt;&lt;/a&gt;&lt;h4&gt;Listing Deployed Web Modules&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-184"&gt;&lt;/a&gt;The Application Server provides two ways to view the deployed web modules: the
Admin Console and the &lt;tt&gt;asadmin&lt;/tt&gt; command.&lt;/p&gt;&lt;p&gt;To use the Admin Console:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Open the URL &lt;tt&gt;http://localhost:4848/asadmin&lt;/tt&gt; in a browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the nodes Applications&amp;#8594;Web Applications.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Use the &lt;tt&gt;asadmin&lt;/tt&gt; command as follows:&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;asadmin list-components&lt;/b&gt;&lt;/tt&gt;&lt;/pre&gt;

&lt;a name="bnaej"&gt;&lt;/a&gt;&lt;h4&gt;Updating Web Modules&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-185"&gt;&lt;/a&gt;&lt;a name="indexterm-186"&gt;&lt;/a&gt;A typical iterative development cycle involves deploying a web module and then making
changes to the application components. To update a deployed web module, you must
do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Recompile any modified classes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have deployed a packaged web module, update any modified components in the WAR.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redeploy the module.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reload the URL in the client.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnaek"&gt;&lt;/a&gt;&lt;h5&gt;Updating a Packaged Web Module&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-187"&gt;&lt;/a&gt;This section describes how to update the &lt;tt&gt;hello1&lt;/tt&gt; web module that you packaged.&lt;/p&gt;&lt;p&gt;First, change the greeting in the file &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello1/web/index.jsp&lt;/tt&gt; to&lt;/p&gt;&lt;pre&gt;&amp;lt;h2&amp;gt;Hi, my name is Duke. What’s yours?&amp;lt;/h2&amp;gt;&lt;/pre&gt;&lt;p&gt;To update the project in NetBeans IDE:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Right-click on the project and select Build Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Right-click on the project and select Deploy Project.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To update the project using the Ant build tool:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt; to copy the modified JSP page into the &lt;tt&gt;build&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt; to deploy the WAR file.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To view the modified module, reload the URL in the browser.&lt;/p&gt;&lt;p&gt;You should see the screen in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadx.html#bnael"&gt;Figure 3-6&lt;/a&gt; in the browser.&lt;/p&gt;&lt;a name="bnael"&gt;&lt;/a&gt;&lt;h6&gt;Figure 3-6 New Greeting&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-newGreeting.gif" alt="Screen capture of Duke&amp;#8216;s new greeting, " hi,="" my="" is="" duke.="" what="" s="" yours?="" includes="" a="" text="" field="" for="" your="" name="" submit="" and="" reset="" buttons.="" height="350" width="662"&gt;

&lt;a name="bnaem"&gt;&lt;/a&gt;&lt;h5&gt;Dynamic Reloading&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-188"&gt;&lt;/a&gt;If dynamic reloading is enabled, you do not have to redeploy an application
or module when you change its code or deployment descriptors. All you have
to do is copy the changed JSP or class files into the
deployment directory for the application or module. The deployment directory for a web module
named &lt;i&gt;context-root&lt;/i&gt; is &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;domain-dir&lt;/i&gt;&lt;tt&gt;/applications/j2ee-modules/&lt;/tt&gt;&lt;i&gt;context-root&lt;/i&gt;&lt;tt&gt;&lt;/tt&gt;. The server checks for changes periodically and redeploys the
application, automatically and dynamically, with the changes.&lt;/p&gt;&lt;p&gt;This capability is useful in a development environment, because it allows code changes
to be tested quickly. Dynamic reloading is not recommended for a production environment,
however, because it may degrade performance. In addition, whenever a reload is done,
the sessions at that time become invalid and the client must restart the
session.&lt;/p&gt;&lt;p&gt;To enable dynamic reloading, use the Admin Console:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Select the Applications Server node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Advanced tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check the Reload Enabled box to enable dynamic reloading.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a number of seconds in the Reload Poll Interval field to
set the interval at which applications and modules are checked for code
changes and dynamically reloaded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Save button.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;In addition, to load new servlet files or reload deployment descriptor changes, you
must do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Create an empty file named &lt;tt&gt;.reload&lt;/tt&gt; at the root of the module:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;domain-dir&lt;/i&gt;/applications/j2ee-modules/&lt;i&gt;context-root&lt;/i&gt;/.reload&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicitly update the &lt;tt&gt;.reload&lt;/tt&gt; file’s time stamp each time you make these changes. On UNIX, execute&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;touch .reload&lt;/b&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;For JSP pages, changes are reloaded automatically at a frequency set in the
Reload Poll Interval field. To disable dynamic reloading of JSP pages, set the
Reload Poll Interval field value to –1.&lt;a name="indexterm-189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;a name="bnaen"&gt;&lt;/a&gt;&lt;h4&gt;Undeploying Web Modules&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-190"&gt;&lt;/a&gt;You can undeploy web modules in four ways: you can use NetBeans
IDE, the Admin Console, the &lt;tt&gt;asadmin&lt;/tt&gt; command, or the Ant tool.&lt;/p&gt;&lt;p&gt;To use NetBeans IDE:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Ensure the Sun Java System Application Server is running.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Runtime window, expand the Sun Java System Application Server instance and the node containing the application or module.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Right-click the application or module and choose Undeploy.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To use the Admin Console:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Open the URL &lt;tt&gt;http://localhost:4848/asadmin&lt;/tt&gt; in a browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Applications node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Web Applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the check box next to the module you wish to undeploy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Undeploy button.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Use the &lt;tt&gt;asadmin&lt;/tt&gt; command as follows:&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;asadmin undeploy &lt;/b&gt;&lt;/tt&gt;&lt;b&gt;&lt;i&gt;context-root&lt;/i&gt;&lt;tt&gt;&lt;/tt&gt;&lt;/b&gt;&lt;/pre&gt;&lt;p&gt;To use the Ant tool, execute the following command in the directory where
you built and packaged the WAR:&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;b&gt;ant undeploy&lt;/b&gt;&lt;/tt&gt;&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="23457629470" hide="0">
			<date>January  20, 2008</date>
			<title>Configuring Web Applications</title>
			<description>&lt;p&gt;Web applications are configured by means of elements contained in the web 
	application deployment descriptor.&lt;/p&gt;
&lt;p&gt;The following sections give a brief introduction to the web application features 
	you will usually want to configure. A number of security parameters can be 
	specified; these are covered in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bncas.html"&gt;
		Chapter 30, Securing Web Applications&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the following sections, examples demonstrate procedures for configuring the 
	Hello, World application. If Hello, World does not use a specific configuration 
	feature, the section gives references to other examples that illustrate how to 
	specify the deployment descriptor element.&lt;/p&gt;
&lt;a name="bnaep"&gt;&lt;/a&gt;
&lt;h4&gt;Mapping URLs to Web Components&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-192"&gt;&lt;/a&gt;When a request is received by the web container it 
	must determine which web component should handle the request. It does so by 
	mapping the URL path contained in the request to a web application and a web 
	component. A URL path contains the context root and an alias:&lt;/p&gt;
&lt;pre&gt;http://&lt;i&gt;host&lt;/i&gt;:&lt;i&gt;port&lt;/i&gt;/&lt;i&gt;context-root&lt;/i&gt;/&lt;i&gt;alias&lt;/i&gt;&lt;/pre&gt;
&lt;a name="bnaeq"&gt;&lt;/a&gt;
&lt;h5&gt;Setting the Component Alias&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-193"&gt;&lt;/a&gt;The &lt;b&gt;alias&lt;/b&gt; identifies the web component that 
	should handle a request. The alias path must start with a forward slash (&lt;tt&gt;/&lt;/tt&gt;) 
	and end with a string or a wildcard expression with an extension (for example, &lt;tt&gt;*.jsp&lt;/tt&gt;). 
	Since web containers automatically map an alias that ends with &lt;tt&gt;*.jsp&lt;/tt&gt;, 
	you do not have to specify an alias for a JSP page unless you wish to refer to 
	the page by a name other than its file name.&lt;/p&gt;
&lt;p&gt;The &lt;tt&gt;hello2&lt;/tt&gt; application has two servlets that need to be mapped in the &lt;tt&gt;web.xml&lt;/tt&gt;
	file. You can edit a web applicationfs &lt;tt&gt;web.xml&lt;/tt&gt; file in NetBeans IDE by 
	doing the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Select File¨Open Project.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;
		&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Select the &lt;tt&gt;hello2&lt;/tt&gt; folder.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Select the Open as Main Project check box.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Open Project Folder.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the project tree in the Projects pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Web pages node and then the WEB-INF node in the project tree.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Double-click the &lt;tt&gt;web.xml&lt;/tt&gt; file inside the WEB-INF node.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The following steps describe how to make the necessary edits to the &lt;tt&gt;web.xml&lt;/tt&gt;
	file, including how to set the display name and how to map the servlet 
	components. Because the edits are already in the file, you can just use the 
	steps to view the settings.&lt;/p&gt;
&lt;p&gt;To set the display name:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Click General at the top of the editor to open the general view.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter &lt;tt&gt;hello2&lt;/tt&gt; in the Display Name field.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To perform the servlet mappings:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Click Servlets at the top of the editor to open the servlets view.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Add Servlet.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Add Servlet dialog, enter &lt;tt&gt;GreetingServlet&lt;/tt&gt; in the Servlet Name 
			field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter &lt;tt&gt;servlets.GreetingServlet&lt;/tt&gt; in the Servlet Class field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter &lt;tt&gt;/greeting&lt;/tt&gt; in the URL Pattern field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click OK.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Repeat the preceding steps, except enter &lt;tt&gt;ResponseServlet&lt;/tt&gt; as the servlet 
			name, &lt;tt&gt;servlets.ResponseServlet&lt;/tt&gt; as the servlet class, and &lt;tt&gt;/response&lt;/tt&gt;
			as the URL pattern.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you are not using NetBeans IDE, you can add these settings using a text 
	editor.&lt;/p&gt;
&lt;p&gt;To package the example with NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Select File¨Open Project.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;
		&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Select the &lt;tt&gt;hello2&lt;/tt&gt; folder.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Select the Open as Main Project check box.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Open Project Folder.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;hello2&lt;/tt&gt; project and select Build 
			Project.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To package the example with the Ant utility, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello2/&lt;/tt&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This target will build the WAR file and copy it to the &lt;tt&gt;
			&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/hello2/dist/&lt;/tt&gt; directory.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To deploy the example using NetBeans IDE, right-click on the project in the 
	Projects pane and select Deploy Project.&lt;/p&gt;
&lt;p&gt;To deploy the example using Ant, type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;. The deploy 
	target in this case gives you an incorrect URL to run the application. To run 
	the application, please use the URL shown at the end of this section.&lt;/p&gt;
&lt;p&gt;To run the application, first deploy the web module, and then open the URL &lt;tt&gt;http://localhost:8080/hello2/greeting&lt;/tt&gt;
	in a browser.&lt;/p&gt;
&lt;a name="bnaer"&gt;&lt;/a&gt;
&lt;h4&gt;Declaring Welcome Files&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-194"&gt;&lt;/a&gt;The &lt;b&gt;welcome files&lt;/b&gt; mechanism allows you to 
	specify a list of files that the web container will use for appending to a 
	request for a URL (called a &lt;b&gt;valid partial request&lt;/b&gt;) that is not mapped to 
	a web component.&lt;/p&gt;
&lt;p&gt;For example, suppose you define a welcome file &lt;tt&gt;welcome.html&lt;/tt&gt;. When a 
	client requests a URL such as &lt;tt&gt;&lt;i&gt;host&lt;/i&gt;:&lt;i&gt;port&lt;/i&gt;/&lt;i&gt;webapp&lt;/i&gt;/&lt;i&gt;directory&lt;/i&gt;&lt;/tt&gt;, 
	where &lt;i&gt;directory&lt;/i&gt; is not mapped to a servlet or JSP page, the file &lt;tt&gt;&lt;/tt&gt;
	&lt;i&gt;host&lt;/i&gt;&lt;tt&gt;:&lt;/tt&gt;&lt;i&gt;port&lt;/i&gt;&lt;tt&gt;/&lt;/tt&gt;&lt;i&gt;webapp&lt;/i&gt;&lt;tt&gt;/&lt;/tt&gt;&lt;i&gt;directory&lt;/i&gt;&lt;tt&gt;/welcome.html&lt;/tt&gt;
	is returned to the client.&lt;/p&gt;
&lt;p&gt;If a web container receives a valid partial request, the web container examines 
	the welcome file list and appends to the partial request each welcome file in 
	the order specified and checks whether a static resource or servlet in the WAR 
	is mapped to that request URL. The web container then sends the request to the 
	first resource in the WAR that matches.&lt;/p&gt;
&lt;p&gt;If no welcome file is specified, the Application Server will use a file named &lt;tt&gt;index.&lt;/tt&gt;&lt;i&gt;XXX&lt;/i&gt;&lt;tt&gt;&lt;/tt&gt;, 
	where &lt;i&gt;XXX&lt;/i&gt; can be &lt;tt&gt;html&lt;/tt&gt; or &lt;tt&gt;jsp&lt;/tt&gt;, as the default welcome 
	file. If there is no welcome file and no file named &lt;tt&gt;index.&lt;/tt&gt;&lt;i&gt;XXX&lt;/i&gt;&lt;tt&gt;&lt;/tt&gt;, 
	the Application Server returns a directory listing.&lt;/p&gt;
&lt;p&gt;To specify a welcome file in the web application deployment descriptor using 
	NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Open the project if you havenft already.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the projectfs node in the Projects pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Do one of the following, making sure that the JSP pages you specify are actually 
			included in the WAR file:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Click Pages at the top of the editor pane and enter the names of the JSP pages 
			that act as welcome files in the Welcome Files field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click XML at the top of the editor pane, specify the JSP pages using &lt;tt&gt;welcome-file&lt;/tt&gt;
			elements and include these elements inside a &lt;tt&gt;welcome-file-list&lt;/tt&gt; element. 
			The &lt;tt&gt;welcome-file&lt;/tt&gt; element defines the JSP page to be used as the 
			welcome page.&lt;/p&gt;
		&lt;p&gt;The example discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html"&gt;
				Encapsulating Reusable Content Using Tag Files&lt;/a&gt; has a welcome file.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;&lt;/ol&gt; &lt;a name="bnaes"&gt;&lt;/a&gt;
&lt;h4&gt;Setting Initialization Parameters&lt;/h4&gt;
&lt;a name="indexterm-195"&gt;&lt;/a&gt;
&lt;p&gt;The web components in a web module share an object that represents their 
	application context (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagl.html"&gt;
		Accessing the Web Context&lt;/a&gt;). You can pass initialization parameters to 
	the context or to a web component.&lt;/p&gt;
&lt;p&gt;To add a context parameter using NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Open the project if you havenft already.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the projectfs node in the Projects pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click General at the top of the editor pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Select the Context Parameters node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Add.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Add Context Parameter dialog, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the name that specifies the context object in the Param Name field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the parameter to pass to the context object in the Param Value field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click OK.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Alternatively, you can edit the XML of the &lt;tt&gt;web.xml&lt;/tt&gt; file directly by 
	clicking XML at the top of the editor pane and using the following elements to 
	add a context parameter:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;param-name&lt;/tt&gt; element that specifies the context object&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;param-value&lt;/tt&gt; element that specifies the parameter to pass to the 
			context object&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;context-param&lt;/tt&gt; element that encloses the previous two elements&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For a sample context parameter, see the example discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahb.html"&gt;
		The Example JSP Pages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a name="indexterm-196"&gt;&lt;/a&gt;To add a web component initialization parameter 
	using NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Open the project if you havenft already.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the projectfs node in the Projects pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Servlets at the top of the editor pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;After entering the servletfs name, class, and URL pattern, click the Add button 
			under the Initialization Parameters table.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Add Initialization Parameter dialog:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the name of the parameter in the Param Name field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the parameterfs value in the Param Value Field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click OK.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Alternatively, you can edit the XML of the &lt;tt&gt;web.xml&lt;/tt&gt; file directly by 
	clicking XML at the top of the editor pane and using the following elements to 
	add a context parameter:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;param-name&lt;/tt&gt; element that specifies the name of the initialization 
			parameter&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;param-value&lt;/tt&gt; element that specifies the value of the initialization 
			parameter&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;An &lt;tt&gt;init-param&lt;/tt&gt; element that encloses the previous two elements&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="bnaet"&gt;&lt;/a&gt;
&lt;h4&gt;Mapping Errors to Error Screens&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-197"&gt;&lt;/a&gt;&lt;a name="indexterm-198"&gt;&lt;/a&gt;&lt;a name="indexterm-199"&gt;&lt;/a&gt;&lt;a name="indexterm-200"&gt;&lt;/a&gt;When 
	an error occurs during execution of a web application, you can have the 
	application display a specific error screen according to the type of error. In 
	particular, you can specify a mapping between the status code returned in an 
	HTTP response or a Java programming language exception returned by any web 
	component (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafi.html#bnafn"&gt;
		Handling Servlet Errors&lt;/a&gt;) and any type of error screen.&lt;/p&gt;
&lt;p&gt;To set up error mappings using NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Open the project if you havenft already.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the projectfs node in the Projects pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Pages at the top of the editor pane.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Expand the Error Pages node.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click Add.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;In the Add Error Page dialog:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;
		&lt;p&gt;Click Browse to locate the page that you want to act as the error page.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the HTTP status code that will cause the error page to be opened in the 
			Error Code field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Enter the exception that will cause the error page to load in the Exception Type 
			field.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Click OK.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Alternatively, you can click XML at the top of the editor pane and enter the 
	error page mapping by hand using the following elements:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;An &lt;tt&gt;exception-type&lt;/tt&gt; element specifying either the exception or the HTTP 
			status code that will cause the error page to be opened.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;A &lt;tt&gt;location&lt;/tt&gt; element that specifies the name of a web resource to be 
			invoked when the status code or exception is returned. The name should have a 
			leading forward slash (&lt;tt&gt;/&lt;/tt&gt;).&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;An &lt;tt&gt;error-page&lt;/tt&gt; element that encloses the previous two elements.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can have multiple &lt;tt&gt;error-page&lt;/tt&gt; elements in your deployment 
	descriptor. Each one of the elements identifies a different error that causes 
	an error page to open. This error page can be the same for any number of &lt;tt&gt;error-page&lt;/tt&gt;
	elements.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;b&gt;Note - &lt;/b&gt;You can also define error screens for a JSP page contained in a 
	WAR. If error screens are defined for both the WAR and a JSP page, the JSP 
	pagefs error page takes precedence. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahe.html#bnahi"&gt;
		Handling JSP Page Errors&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;For a sample error page mapping, see the example discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaff.html"&gt;
		The Example Servlets&lt;/a&gt;.&lt;/p&gt;
&lt;a name="bnaeu"&gt;&lt;/a&gt;
&lt;h4&gt;Declaring Resource References&lt;/h4&gt;
&lt;p&gt;If your web component uses objects such as enterprise beans, data sources, or 
	web services, you use Java EE annotations to inject these resources into your 
	application. Annotations eliminate a lot of the boilerplate lookup code and 
	configuration elements that previous versions of Java EE required.&lt;/p&gt;
&lt;p&gt;Although resource injection using annotations can be more convenient for the 
	developer, there are some restrictions from using it in web applications. 
	First, you can only inject resources into container-managed objects. This is 
	because a container must have control over the creation of a component so that 
	it can perform the injection into a component. As a result, you cannot inject 
	resources into objects such as simple JavaBeans components. However, JavaServer 
	Faces managed beans are managed by the container; therefore, they can accept 
	resource injections.&lt;/p&gt;
&lt;p&gt;Additionally, JSP pages cannot accept resource injections. This is because the 
	information represented by annotations must be available at deployment time, 
	but the JSP page is compiled after that; therefore, the annotation will not be 
	seen when it is needed. Those components that can accept resource injections 
	are listed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaeo.html#bnaev"&gt;
		Table 3-1&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This section describes how to use a couple of the annotations supported by a 
	servlet container to inject resources. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbrl.html"&gt;
		Chapter 25, Persistence in the Web Tier&lt;/a&gt; describes how web applications 
	use annotations supported by the Java Persistence API. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bncas.html"&gt;
		Chapter 30, Securing Web Applications&lt;/a&gt; describes how to use annotations 
	to specify information about securing web applications.&lt;/p&gt;
&lt;a name="bnaev"&gt;&lt;/a&gt;
&lt;h6&gt;Table 3-1 Web Components That Accept Resource Injections&lt;/h6&gt;
&lt;table ID="Table1"&gt;
	&lt;col width="75*"&gt;
	&lt;col width="253*"&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;th align="left" valign="top"&gt;
				&lt;p&gt;Component&lt;/p&gt;
			&lt;/th&gt;
			&lt;th align="left" valign="top"&gt;
				&lt;p&gt;Interface/Class&lt;/p&gt;
			&lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Servlets&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;javax.servlet.Servlet&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Servlet Filters&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;javax.servlet.ServletFilter&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Event Listeners&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;javax.servlet.ServletContextListener&lt;/tt&gt;&lt;/p&gt;
				&lt;p&gt;&lt;tt&gt;javax.servlet.ServletContextAttributeListener&lt;/tt&gt;&lt;/p&gt;
				&lt;p&gt;&lt;tt&gt;javax.servlet.ServletRequestListener&lt;/tt&gt;&lt;/p&gt;
				&lt;p&gt;&lt;tt&gt;javax.servlet.ServletRequestAttributeListener&lt;/tt&gt;&lt;/p&gt;
				&lt;p&gt;&lt;tt&gt;javax.servlet.http.HttpSessionListener&lt;/tt&gt;&lt;/p&gt;
				&lt;p&gt;&lt;tt&gt;javax.servlet.http.HttpSessionAttributeListener&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Taglib Listeners&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Same as above&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Taglib Tag Handlers&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;javax.servlet.jsp.tagext.JspTag&lt;/tt&gt;&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Managed Beans&lt;/p&gt;
			&lt;/td&gt;
			&lt;td align="left" valign="top"&gt;&lt;p&gt;Plain Old Java Objects&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;a name="bnaew"&gt;&lt;/a&gt;
&lt;h5&gt;Declaring a Reference to a Resource&lt;/h5&gt;
&lt;p&gt;The &lt;tt&gt;@Resource&lt;/tt&gt; annotation is used to declare a reference to a resource 
	such as a data source, an enterprise bean, or an environment entry. This 
	annotation is equivalent to declaring a &lt;tt&gt;resource-ref&lt;/tt&gt; element in the 
	deployment descriptor.&lt;/p&gt;
&lt;p&gt;The &lt;tt&gt;@Resource&lt;/tt&gt; annotation is specified on a class, method or field. The 
	container is responsible for injecting references to resources declared by the &lt;tt&gt;@Resource&lt;/tt&gt;
	annotation and mapping it to the proper JNDI resources. In the following 
	example, the &lt;tt&gt;@Resource&lt;/tt&gt; annotation is used to inject a data source into 
	a component that needs to make a connection to the data source, as is done when 
	using JDBC technology to access a relational database:&lt;/p&gt;
&lt;pre&gt;@Resource javax.sql.DataSource catalogDS;
public getProductsByCategory() {
    // get a connection and execute the query
    Connection conn = catalogDS.getConnection();
    ..
}&lt;/pre&gt;
&lt;p&gt;The container injects this data source prior to the component being made 
	available to the application. The data source JNDI mapping is inferred from the 
	field name &lt;tt&gt;catalogDS&lt;/tt&gt; and the type, &lt;tt&gt;javax.sql.DataSource&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;If you have multiple resources that you need to inject into one component, you 
	need to use the &lt;tt&gt;@Resources&lt;/tt&gt; annotation to contain them, as shown by the 
	following example:&lt;/p&gt;
&lt;pre&gt;@Resources ({
    @Resource (name="myDB" type=java.sql.DataSource),
    @Resource(name="myMQ" type=javax.jms.ConnectionFactory)
})&lt;/pre&gt;
&lt;p&gt;The web application examples in this tutorial use the Java Persistence API to 
	access relational databases. This API does not require you to explicitly create 
	a connection to a data source. Therefore, the examples do not use the &lt;tt&gt;@Resource&lt;/tt&gt;
	annotation to inject a data source. However, this API supports the &lt;tt&gt;@PersistenceUnit&lt;/tt&gt;
	and &lt;tt&gt;@PersistenceContext&lt;/tt&gt; annotations for injecting &lt;tt&gt;EntityManagerFactory&lt;/tt&gt;
	and &lt;tt&gt;EntityManager&lt;/tt&gt; instances, respectively. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbrl.html"&gt;
		Chapter 25, Persistence in the Web Tier&lt;/a&gt; describes these annotations and 
	the use of the Java Persistence API in web applications.&lt;/p&gt;
&lt;a name="bnaex"&gt;&lt;/a&gt;
&lt;h5&gt;Declaring a Reference to a Web Service&lt;/h5&gt;
&lt;p&gt;The &lt;tt&gt;@WebServiceRef&lt;/tt&gt; annotation provides a reference to a web service. 
	The following example shows uses the &lt;tt&gt;@WebServiceRef&lt;/tt&gt; annotation to 
	declare a reference to a web service. &lt;tt&gt;WebServiceRef&lt;/tt&gt; uses the &lt;tt&gt;wsdlLocation&lt;/tt&gt;
	element to specify the URI of the deployed servicefs WSDL file:&lt;/p&gt;
&lt;pre&gt;...
import javax.xml.ws.WebServiceRef;
...
public class ResponseServlet extends HTTPServlet {
@WebServiceRef(wsdlLocation=
    "http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="13750206126" hide="0">
			<date>January  20, 2008</date>
			<title>Accessing Databases from Web Applications</title>
			<description>&lt;p&gt;Data that is shared between web components and is persistent between invocations of
a web application is usually maintained in a database. To maintain a catalog
of books, the Duke’s Bookstore examples described in Chapters &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt; through &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaxu.html"&gt;Chapter 15, Internationalizing and Localizing Web Applications&lt;/a&gt; use
the Java DB database included with the Application Server.&lt;/p&gt;&lt;p&gt;To access the data in a database, web applications use the new
Java Persistence API (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpz.html"&gt;Chapter 24, Introduction to the Java Persistence API&lt;/a&gt;). See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbrl.html"&gt;Chapter 25, Persistence in the Web Tier&lt;/a&gt; to learn how the Duke’s Bookstore applications
use this API to access the book data.&lt;/p&gt;&lt;p&gt;To run the Duke’s Bookstore applications, you need to first populate the database
with the book data and create a data source in the application server.
The rest of this section explains how to perform these tasks.&lt;/p&gt;

&lt;a name="bnafa"&gt;&lt;/a&gt;&lt;h4&gt;Populating the Example Database&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-204"&gt;&lt;/a&gt;When you deploy any of the Duke’s Bookstore applications using &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;, the database is
automatically populated at the same time. If you want to populate the database
separately from the deploy task or are using NetBeans IDE to deploy the
application, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to the &lt;tt&gt;books&lt;/tt&gt; directory or any one of the &lt;tt&gt;bookstore1&lt;/tt&gt; through &lt;tt&gt;bookstore6&lt;/tt&gt; example directories.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Java DB database server. For instructions, see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadk.html"&gt;Starting and Stopping the Java DB Database Server&lt;/a&gt;. You don’t have to do this if you are using NetBeans IDE. It starts the database server automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant create-tables&lt;/b&gt;&lt;/tt&gt;. This task runs a command to read the file &lt;tt&gt;tutorial.sql&lt;/tt&gt; and execute the SQL commands contained in the file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At the end of the processing, you should see the following output:&lt;/p&gt;&lt;pre&gt;...
[sql] 181 of 181 SQL statements executed successfully&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;When you are running &lt;tt&gt;create-tables&lt;/tt&gt;, don’t worry if you see a message that
an SQL statement failed. This usually happens the first time you run the
command because it always tries to delete an existing database table first before
it creates a new one. The first time through, there is no table
yet, of course.&lt;/p&gt;

&lt;a name="bnafb"&gt;&lt;/a&gt;&lt;h4&gt;Creating a Data Source in the Application Server&lt;/h4&gt;
&lt;p&gt;A &lt;tt&gt;DataSource&lt;/tt&gt; object has a set of properties that identify and describe the
real world data source that it represents. These properties include information such as
the location of the database server, the name of the database, the network
protocol to use to communicate with the server, and so on.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-205"&gt;&lt;/a&gt;Data sources in the Application Server implement connection pooling. To define the Duke’s
Bookstore data source, you use the installed Derby connection pool named &lt;tt&gt;DerbyPool&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;You create the data source using the Application Server Admin Console, following this
procedure:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the Resources node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the JDBC node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the JDBC Resources node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the New... button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;jdbc/BookDB&lt;/tt&gt; in the JNDI Name field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose &lt;tt&gt;DerbyPool&lt;/tt&gt; for the Pool Name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click OK.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;</description>
		</newsitem>
		<newsitem id="10315007433" hide="0">
			<date>January  20, 2008</date>
			<title>Java Servlet Technology</title>
			<description>As soon as the web began to be used for delivering services,
service providers recognized the need for dynamic content. Applets, one of the earliest attempts
toward this goal, focused on using the client platform to deliver dynamic user
experiences. At the same time, developers also investigated using the server platform for
this purpose. Initially, Common Gateway Interface (CGI) scripts were the main technology used
to generate dynamic content. Although widely used, CGI scripting technology has a number
of shortcomings, including platform dependence and lack of scalability. To address these limitations, Java
Servlet technology was created as a portable way to provide dynamic, user-oriented content.</description>
		</newsitem>
		<newsitem id="36295378106" hide="0">
			<date>January  20, 2008</date>
			<title>What Is a Servlet?</title>
			<description>&lt;p&gt;A &lt;b&gt;servlet&lt;/b&gt; is a Java programming language class that is used to extend
the capabilities of servers that host applications accessed by means of a request-response
programming model. Although servlets can respond to any type of request, they are
commonly used to extend the applications hosted by web servers. For such applications,
Java Servlet technology defines HTTP-specific servlet classes.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-207"&gt;&lt;/a&gt;&lt;a name="indexterm-208"&gt;&lt;/a&gt;&lt;a name="indexterm-209"&gt;&lt;/a&gt;&lt;a name="indexterm-210"&gt;&lt;/a&gt;&lt;a name="indexterm-211"&gt;&lt;/a&gt;The &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/package-summary.html"&gt;javax.servlet&lt;/a&gt; and &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/package-summary.html"&gt;javax.servlet.http&lt;/a&gt; packages provide interfaces and classes for writing servlets. All
servlets must implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/Servlet.html"&gt;Servlet&lt;/a&gt; interface, which defines life-cycle methods. When implementing a
generic service, you can use or extend the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html"&gt;GenericServlet&lt;/a&gt; class provided with
the Java Servlet API. The &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServlet.html"&gt;HttpServlet&lt;/a&gt; class provides methods, such as &lt;tt&gt;doGet&lt;/tt&gt; and
&lt;tt&gt;doPost&lt;/tt&gt;, for handling HTTP-specific services.&lt;/p&gt;&lt;p&gt;This chapter focuses on writing servlets that generate responses to HTTP requests. &lt;/p&gt;</description>
		</newsitem>
		<newsitem id="36969977117" hide="0">
			<date>January  20, 2008</date>
			<title>Servlet Life Cycle</title>
			<description>&lt;p&gt;The life cycle of a servlet is controlled by the container in
which the servlet has been deployed. When a request is mapped to a
servlet, the container performs the following steps.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-214"&gt;&lt;/a&gt;If an instance of the servlet does not exist, the web container&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Loads the servlet class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creates an instance of the servlet class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initializes the servlet instance by calling the &lt;tt&gt;init&lt;/tt&gt; method. Initialization is covered in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafu.html"&gt;Initializing a Servlet&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Invokes the &lt;tt&gt;service&lt;/tt&gt; method, passing request and response objects. Service methods are discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html"&gt;Writing Service Methods&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;If the container needs to remove the servlet, it finalizes the servlet by
calling the servlet’s &lt;tt&gt;destroy&lt;/tt&gt; method. Finalization is discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnags.html"&gt;Finalizing a Servlet&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnafj"&gt;&lt;/a&gt;&lt;h4&gt;Handling Servlet Life-Cycle Events&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-215"&gt;&lt;/a&gt;&lt;a name="indexterm-216"&gt;&lt;/a&gt;You can monitor and react to events in a servlet’s life cycle by
defining listener objects whose methods get invoked when life-cycle events occur. To use
these listener objects you must define and specify the listener class.&lt;/p&gt;

&lt;a name="bnafk"&gt;&lt;/a&gt;&lt;h5&gt;Defining the Listener Class&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-217"&gt;&lt;/a&gt;&lt;a name="indexterm-218"&gt;&lt;/a&gt;You define a listener class as an implementation of a listener interface. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafi.html#bnafl"&gt;Table 4-2&lt;/a&gt;
lists the events that can be monitored and the corresponding interface that must
be implemented. When a listener method is invoked, it is passed an event
that contains information appropriate to the event. For example, the methods in the
&lt;tt&gt;HttpSessionListener&lt;/tt&gt; interface are passed an &lt;tt&gt;HttpSessionEvent&lt;/tt&gt;, which contains an &lt;tt&gt;HttpSession&lt;/tt&gt;.&lt;/p&gt;&lt;a name="bnafl"&gt;&lt;/a&gt;&lt;h6&gt;Table 4-2 Servlet Life-Cycle Events&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="75*"&gt;&lt;col width="76*"&gt;&lt;col width="203*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Object&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Event&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Listener Interface and Event
Class&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;Web context (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagl.html"&gt;Accessing the Web Context&lt;/a&gt;)&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Initialization and destruction&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextListener.html"&gt;javax.servlet.ServletContextListener&lt;/a&gt; and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextEvent.html"&gt;ServletContextEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Attribute added, removed, or replaced&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextAttributeListener.html"&gt;javax.servlet.ServletContextAttributeListener&lt;/a&gt; and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextAttributeEvent.html"&gt;ServletContextAttributeEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;Session
(See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagm.html"&gt;Maintaining Client State&lt;/a&gt;)&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Creation, invalidation, activation, passivation, and timeout&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionListener.html"&gt;javax.servlet.http.HttpSessionListener&lt;/a&gt;, &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionActivationListener.html"&gt;javax.servlet.http.HttpSessionActivationListener&lt;/a&gt;, and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionEvent.html"&gt;HttpSessionEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Attribute added, removed, or
replaced&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionAttributeListener.html"&gt;javax.servlet.http.HttpSessionAttributeListener&lt;/a&gt; and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionBindingEvent.html"&gt;HttpSessionBindingEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;Request&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;A servlet request has started being processed by web components&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestListener.html"&gt;javax.servlet.ServletRequestListener&lt;/a&gt; and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestEvent.html"&gt;ServletRequestEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Attribute
added, removed, or replaced&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestAttributeListener.html"&gt;javax.servlet.ServletRequestAttributeListener&lt;/a&gt; and&lt;/p&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestAttributeEvent.html"&gt;ServletRequestAttributeEvent&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a name="indexterm-219"&gt;&lt;/a&gt;The &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore1/src/java/com/sun/bookstore1/listeners/ContextListener&lt;/tt&gt; class creates and removes the database access and counter objects used
in the Duke’s Bookstore application. The methods retrieve the web context object from
&lt;tt&gt;ServletContextEvent&lt;/tt&gt; and then store (and remove) the objects as servlet context attributes.&lt;/p&gt;&lt;pre&gt;import database.BookDBAO;
import javax.servlet.*;
import util.Counter;

import javax.ejb.*;
import javax.persistence.*;

public final class ContextListener
    implements ServletContextListener {
    private ServletContext context = null;

    @PersistenceUnit
    EntityManagerFactory emf;

    public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();
        try {
            BookDBAO bookDB = new BookDBAO(emf);
            context.setAttribute("bookDB", bookDB);
        } catch (Exception ex) {
            System.out.println(
                "Couldn’t create database: " + ex.getMessage());
        }
        Counter counter = new Counter();
        context.setAttribute("hitCounter", counter);
        counter = new Counter();
        context.setAttribute("orderCounter", counter);
    }

    public void contextDestroyed(ServletContextEvent event) {
        context = event.getServletContext();
        BookDBAO bookDB = context.getAttribute("bookDB");
        bookDB.remove();
        context.removeAttribute("bookDB");
        context.removeAttribute("hitCounter");
        context.removeAttribute("orderCounter");
    }
}&lt;/pre&gt;

&lt;a name="bnafm"&gt;&lt;/a&gt;&lt;h5&gt;Specifying Event Listener Classes&lt;/h5&gt;
&lt;p&gt;You specify an event listener class using the &lt;tt&gt;listener&lt;/tt&gt; element of the deployment
descriptor. Review &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaff.html"&gt;The Example Servlets&lt;/a&gt; for information on how to specify the &lt;tt&gt;ContextListener&lt;/tt&gt; listener class.
&lt;/p&gt;&lt;p&gt;You can specify an event listener using the deployment descriptor editor of NetBeans
IDE by doing the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand your application’s project node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the project’s Web Pages and WEB-INF nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click General at the top of the &lt;tt&gt;web.xml&lt;/tt&gt; editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Web Application Listeners node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Add.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Add Listener dialog, click Browse to locate the listener class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click OK.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;


&lt;a name="bnafn"&gt;&lt;/a&gt;&lt;h4&gt;Handling Servlet Errors&lt;/h4&gt;
&lt;p&gt;Any number of exceptions can occur when a servlet executes. When an exception
occurs, the web container generates a default page containing the message&lt;/p&gt;&lt;pre&gt;A Servlet Exception Has Occurred&lt;/pre&gt;&lt;p&gt;But you can also specify that the container should return a specific error
page for a given exception. Review the deployment descriptor file included with the
example to learn how to map the exceptions &lt;tt&gt;exception.BookNotFound&lt;/tt&gt;, &lt;tt&gt;exception.BooksNotFound&lt;/tt&gt;, and &lt;tt&gt;exception.OrderException&lt;/tt&gt;
returned by the Duke’s Bookstore application to &lt;tt&gt;errorpage.html&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaeo.html#bnaet"&gt;Mapping Errors to Error Screens&lt;/a&gt; for instructions on how to specify error pages using NetBeans IDE.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="112070226" hide="0">
			<date>January  20, 2008</date>
			<title>Sharing Information</title>
			<description>&lt;p&gt;Web components, like most objects, usually work with other objects to accomplish their
tasks. There are several ways they can do this. They can use private
helper objects (for example, JavaBeans components), they can share objects that are attributes
of a public scope, they can use a database, and they can invoke
other web resources. The Java Servlet technology mechanisms that allow a web component
to invoke other web resources are described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagi.html"&gt;Invoking Other Web Resources&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnafp"&gt;&lt;/a&gt;&lt;h4&gt;Using Scope Objects&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-221"&gt;&lt;/a&gt;Collaborating web components share information by means of objects that are maintained as
attributes of four scope objects. You access these attributes using the &lt;tt&gt;[get|set]Attribute&lt;/tt&gt; methods
of the class representing the scope. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafq"&gt;Table 4-3&lt;/a&gt; lists the scope objects.&lt;/p&gt;&lt;a name="bnafq"&gt;&lt;/a&gt;&lt;h6&gt;Table 4-3 Scope Objects&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="55*"&gt;&lt;col width="103*"&gt;&lt;col width="195*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Scope Object&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Class&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Accessible From&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Web context&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html"&gt;javax.servlet.ServletContext&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Web
components within a web context. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagl.html"&gt;Accessing the Web Context&lt;/a&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Session&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html"&gt;javax.servlet.http.HttpSession&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Web components handling a request that
belongs to the session. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagm.html"&gt;Maintaining Client State&lt;/a&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Request&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;subtype of &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html"&gt;javax.servlet.ServletRequest&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Web components handling the request.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Page&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/jsp/JspContext.html"&gt;javax.servlet.jsp.JspContext&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The
JSP page that creates the object. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahl.html#bnahn"&gt;Using Implicit Objects&lt;/a&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafr"&gt;Figure 4-1&lt;/a&gt; shows the scoped attributes maintained by the Duke’s Bookstore application.&lt;/p&gt;&lt;a name="bnafr"&gt;&lt;/a&gt;&lt;h6&gt;Figure 4-1 Duke’s Bookstore Scoped Attributes&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-scopedAttributes.gif" alt="Diagram of Duke&amp;#8216;s Bookstore scoped attributes. Session attributes are currency and cart, web context attributes are hitCounter, bookDB, orderCounter."&gt;

&lt;a name="bnafs"&gt;&lt;/a&gt;&lt;h4&gt;Controlling Concurrent Access to Shared Resources&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-222"&gt;&lt;/a&gt;In a multithreaded server, it is possible for shared resources to be accessed
concurrently. In addition to scope object attributes, shared resources include in-memory data (such
as instance or class variables) and external objects such as files, database connections, and
network connections. &lt;/p&gt;&lt;p&gt;Concurrent access can arise in several situations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Multiple web components accessing objects stored in the web context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Multiple web components accessing objects stored in a session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-223"&gt;&lt;/a&gt;Multiple threads within a web
component accessing instance variables. A web container will typically
create a thread to handle each request. If you want to ensure that a
servlet instance handles only one request at a time, a servlet can
implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/SingleThreadModel.html"&gt;SingleThreadModel&lt;/a&gt;
interface. If a servlet implements this interface, you are guaranteed
that no two threads will execute concurrently in the servlet’s service
method. A web container can implement this guarantee by synchronizing
access to a single instance of the servlet, or by maintaining a pool of
web component instances and dispatching each new request to a free
instance. This interface does not prevent synchronization problems that
result from web components accessing shared resources such as static
class variables or external objects. In addition, the Servlet 2.4
specification deprecates the &lt;tt&gt;SingleThreadModel&lt;/tt&gt; interface.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;When resources can be accessed concurrently, they can be used in an inconsistent
fashion. To prevent this, you must control the access using the synchronization techniques
described in the &lt;a href="http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html"&gt;Threads&lt;/a&gt; lesson in &lt;a href="http://java.sun.com/docs/books/tutorial/"&gt;&lt;i&gt;The Java Tutorial, Fourth Edition&lt;/i&gt;&lt;/a&gt;, by Sharon Zakhour et al. (Addison-Wesley,
2006).&lt;/p&gt;&lt;p&gt;The preceding section showed five scoped attributes shared by more than one servlet:
&lt;tt&gt;bookDB&lt;/tt&gt;, &lt;tt&gt;cart&lt;/tt&gt;, &lt;tt&gt;currency&lt;/tt&gt;, &lt;tt&gt;hitCounter&lt;/tt&gt;, and &lt;tt&gt;orderCounter&lt;/tt&gt;. The &lt;tt&gt;bookDB&lt;/tt&gt; attribute is discussed in the
next section. The cart, currency, and counters can be set and read by
multiple multithreaded servlets. To prevent these objects from being used inconsistently, access is controlled
by synchronized methods. For example, here is the &lt;tt&gt;Counter&lt;/tt&gt; class, located at &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore1/src/java/com/sun/bookstore1/util/&lt;/tt&gt;:&lt;/p&gt;&lt;pre&gt;public class Counter {
    private int counter;
    public Counter() {
        counter = 0;
    }
    public synchronized int getCounter() {
        return counter;
    }
    public synchronized int setCounter(int c) {
        counter = c;
        return counter;
    }
    public synchronized int incCounter() {
        return(++counter);
    }
}&lt;/pre&gt;

&lt;a name="bnaft"&gt;&lt;/a&gt;&lt;h4&gt;Accessing Databases&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-224"&gt;&lt;/a&gt;Data that is shared between web components and is persistent between invocations of
a web application is usually maintained by a database. Web components use the
Java Persistence API to access relational databases. The data for Duke’s Bookstore is
maintained in a database and is accessed through the database access class &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore1/src/java/com/sun/bookstore1/database/BookDBAO&lt;/tt&gt;.
For example, &lt;tt&gt;ReceiptServlet&lt;/tt&gt; invokes the &lt;tt&gt;BookDBAO.buyBooks&lt;/tt&gt; method to update the book inventory
when a user makes a purchase. The &lt;tt&gt;buyBooks&lt;/tt&gt; method invokes &lt;tt&gt;buyBook&lt;/tt&gt; for each
book contained in the shopping cart, as shown in the following code.&lt;/p&gt;&lt;pre&gt;public void buyBooks(ShoppingCart cart) throws OrderException{

    Collection items = cart.getItems();
    Iterator i = items.iterator();
    
    try {
        while (i.hasNext()) {
            ShoppingCartItem sci = (ShoppingCartItem)i.next();
            Book bd = (Book)sci.getItem();
            String id = bd.getBookId();
            int quantity = sci.getQuantity();
            buyBook(id, quantity);
        }
    } catch (Exception ex) {
        throw new OrderException("Commit failed: " +
            ex.getMessage());
     }
}

public void buyBook(String bookId, int quantity)
     throws OrderException {

    try {
        Book requestedBook = em.find(Book.class, bookId);
        
        if (requestedBook != null) {
            int inventory = requestedBook.getInventory();
            if ((inventory - quantity) &amp;gt;= 0) {
                int newInventory = inventory - quantity;
                requestedBook.setInventory(newInventory);
            } else{
                throw new OrderException("Not enough of "
                     + bookId + " in stock to complete order.");
            }
        }
    } catch (Exception ex) {
        throw new OrderException("Couldn’t purchase book: "
             + bookId + ex.getMessage());
    }
}&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-225"&gt;&lt;/a&gt;&lt;a name="indexterm-226"&gt;&lt;/a&gt;To ensure that the order is processed in its entirety, the call to
&lt;tt&gt;buyBooks&lt;/tt&gt; is wrapped in a single transaction. In the following code, the calls
to the &lt;tt&gt;begin&lt;/tt&gt; and &lt;tt&gt;commit&lt;/tt&gt; methods of &lt;tt&gt;UserTransaction&lt;/tt&gt; mark the boundaries of the
transaction. The call to the &lt;tt&gt;rollback&lt;/tt&gt; method of &lt;tt&gt;UserTransaction&lt;/tt&gt; undoes the effects
of all statements in the transaction so as to protect the integrity of
the data.&lt;/p&gt;&lt;pre&gt;try {
    utx.begin();
    bookDB.buyBooks(cart);
    utx.commit();
} catch (Exception ex) {
    try {
        utx.rollback();
    } catch(Exception e) {
        System.out.println("Rollback failed: "+e.getMessage());
    }
    System.err.println(ex.getMessage());
    orderCompleted = false;}
}&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="10054506653" hide="0">
			<date>January  20, 2008</date>
			<title>Initializing a Servlet</title>
			<description>&lt;p&gt;After the web container loads and instantiates the servlet class and before it 
	delivers requests from clients, the web container initializes the servlet. To 
	customize this process to allow the servlet to read persistent configuration 
	data, initialize resources, and perform any other one-time activities, you 
	override the &lt;tt&gt;init&lt;/tt&gt; method of the &lt;tt&gt;Servlet&lt;/tt&gt; interface. A servlet 
	that cannot complete its initialization process should throw &lt;tt&gt;UnavailableException&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;All the servlets that access the bookstore database (&lt;tt&gt;BookStoreServlet&lt;/tt&gt;, &lt;tt&gt;CatalogServlet&lt;/tt&gt;,
	&lt;tt&gt;BookDetailsServlet&lt;/tt&gt;, and &lt;tt&gt;ShowCartServlet&lt;/tt&gt;) initialize a 
	variable in their &lt;tt&gt;init&lt;/tt&gt; method that points to the database access 
	object created by the web context listener:&lt;/p&gt;
&lt;pre&gt;public class CatalogServlet extends HttpServlet {
    private BookDBAO bookDB;
    public void init() throws ServletException {
        bookDB = (BookDBAO)getServletContext().
            getAttribute("bookDB");
        if (bookDB == null) throw new
            UnavailableException("Couldn’t get database.");
    }
}&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="14212247090" hide="0">
			<date>January  20, 2008</date>
			<title>Writing Service Methods</title>
			<description>&lt;p&gt;The service provided by a servlet is implemented in the &lt;tt&gt;service&lt;/tt&gt; method of a
&lt;tt&gt;GenericServlet&lt;/tt&gt;, in the &lt;tt&gt;do&lt;i&gt;Method&lt;/i&gt;&lt;/tt&gt; methods (where &lt;i&gt;Method&lt;/i&gt; can take the value &lt;tt&gt;Get&lt;/tt&gt;, &lt;tt&gt;Delete&lt;/tt&gt;,
&lt;tt&gt;Options&lt;/tt&gt;, &lt;tt&gt;Post&lt;/tt&gt;, &lt;tt&gt;Put&lt;/tt&gt;, or &lt;tt&gt;Trace&lt;/tt&gt;) of an &lt;tt&gt;HttpServlet&lt;/tt&gt; object, or in any other
protocol-specific methods defined by a class that implements the &lt;tt&gt;Servlet&lt;/tt&gt; interface. In the
rest of this chapter, the term &lt;b&gt;service method&lt;/b&gt; is used for any method in
a servlet class that provides a service to a client.&lt;/p&gt;&lt;p&gt;The general pattern for a service method is to extract information from the
request, access external resources, and then populate the response based on that information.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-234"&gt;&lt;/a&gt;For HTTP servlets, the correct procedure for populating the response is to first
retrieve an output stream from the response, then fill in the response headers,
and finally write any body content to the output stream. Response headers must
always be set before the response has been committed. Any attempt to set
or add headers after the response has been committed will be ignored by
the web container. The next two sections describe how to get information from
requests and generate responses.&lt;/p&gt;

&lt;a name="bnafw"&gt;&lt;/a&gt;&lt;h4&gt;Getting Information from Requests&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-235"&gt;&lt;/a&gt;&lt;a name="indexterm-236"&gt;&lt;/a&gt;&lt;a name="indexterm-237"&gt;&lt;/a&gt;&lt;a name="indexterm-238"&gt;&lt;/a&gt;A request contains data passed between a client and the servlet. All requests
implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html"&gt;ServletRequest&lt;/a&gt; interface. This interface defines methods for accessing the following information:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Parameters, which are typically used to convey information between clients and servlets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object-valued attributes, which are typically used to pass
information between the servlet container and a servlet or between
collaborating servlets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Information about the protocol used to communicate the request and about the client and server involved in the request&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Information relevant to localization&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-239"&gt;&lt;/a&gt;For example, in &lt;tt&gt;CatalogServlet&lt;/tt&gt; the identifier of the book that a customer wishes
to purchase is included as a parameter to the request. The following code
fragment illustrates how to use the &lt;tt&gt;getParameter&lt;/tt&gt; method to extract the identifier:&lt;/p&gt;&lt;pre&gt;String bookId = request.getParameter("Add");
if (bookId != null) {
    Book book = bookDB.getBook(bookId);&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-240"&gt;&lt;/a&gt;&lt;a name="indexterm-241"&gt;&lt;/a&gt;&lt;a name="indexterm-242"&gt;&lt;/a&gt;&lt;a name="indexterm-243"&gt;&lt;/a&gt;You can also retrieve an input stream from the request and manually parse
the data. To read character data, use the &lt;a href="http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html"&gt;BufferedReader&lt;/a&gt; object returned by the
request’s &lt;tt&gt;getReader&lt;/tt&gt; method. To read binary data, use the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletInputStream.html"&gt;ServletInputStream&lt;/a&gt; returned by
&lt;tt&gt;getInputStream&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-244"&gt;&lt;/a&gt;&lt;a name="indexterm-245"&gt;&lt;/a&gt;&lt;a name="indexterm-246"&gt;&lt;/a&gt;HTTP servlets are passed an HTTP request object, &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html"&gt;HttpServletRequest&lt;/a&gt;, which contains the request
URL, HTTP headers, query string, and so on.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-247"&gt;&lt;/a&gt;An HTTP request URL contains the following parts:&lt;/p&gt;&lt;pre&gt;http://[&lt;i&gt;host&lt;/i&gt;]:[&lt;i&gt;port&lt;/i&gt;][&lt;i&gt;request-path&lt;/i&gt;]?[&lt;i&gt;query-string&lt;/i&gt;]&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-248"&gt;&lt;/a&gt;The request path is further composed of the following elements:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;b&gt;Context path&lt;/b&gt;: A concatenation of a forward slash (&lt;tt&gt;/&lt;/tt&gt;) with the context root of the servlet’s web application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Servlet path&lt;/b&gt;: The path section that corresponds to the component alias that activated this request. This path starts with a forward slash (&lt;tt&gt;/&lt;/tt&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Path info&lt;/b&gt;: The part of the request path that is not part of the context path or the servlet path.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;If the context path is &lt;tt&gt;/catalog&lt;/tt&gt; and for the aliases listed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html#bnafx"&gt;Table 4-4&lt;/a&gt;,
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html#bnafy"&gt;Table 4-5&lt;/a&gt; gives some examples of how the URL will be parsed.&lt;/p&gt;&lt;a name="bnafx"&gt;&lt;/a&gt;&lt;h6&gt;Table 4-4 Aliases&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="178*"&gt;&lt;col width="178*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Pattern&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Servlet&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/lawn/*&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;LawnServlet&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/*.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;JSPServlet&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;a name="bnafy"&gt;&lt;/a&gt;&lt;h6&gt;Table 4-5 Request Path Elements&lt;/h6&gt;&lt;table ID="Table2"&gt;&lt;col width="162*"&gt;&lt;col width="116*"&gt;&lt;col width="77*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Request Path&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Servlet Path&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Path
Info&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/catalog/lawn/index.html&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/lawn&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/index.html&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/catalog/help/feedback.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;/help/feedback.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;null&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a name="indexterm-249"&gt;&lt;/a&gt;Query strings are composed of a set of parameters and values. Individual parameters
are retrieved from a request by using the &lt;tt&gt;getParameter&lt;/tt&gt; method. There are
two ways to generate query strings:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A query string can explicitly appear in a web page. For example, an HTML page generated by &lt;tt&gt;CatalogServlet&lt;/tt&gt; could contain the link &lt;tt&gt;&amp;lt;a href="/bookstore1/catalog?Add=101"&amp;gt;Add To Cart&amp;lt;/a&amp;gt;&lt;/tt&gt;. &lt;tt&gt;CatalogServlet&lt;/tt&gt; extracts the parameter named &lt;tt&gt;Add&lt;/tt&gt; as follows:&lt;/p&gt;&lt;pre&gt;String bookId = request.getParameter("Add");&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A query string is appended to a URL when a form with a &lt;tt&gt;GET&lt;/tt&gt; HTTP method is submitted. In the Duke’s Bookstore application, &lt;tt&gt;CashierServlet&lt;/tt&gt; generates a form, then a user name input to the form is appended to the URL that maps to &lt;tt&gt;ReceiptServlet&lt;/tt&gt;, and finally &lt;tt&gt;ReceiptServlet&lt;/tt&gt; extracts the user name using the &lt;tt&gt;getParameter&lt;/tt&gt; method.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnafz"&gt;&lt;/a&gt;&lt;h4&gt;Constructing Responses&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-250"&gt;&lt;/a&gt;&lt;a name="indexterm-251"&gt;&lt;/a&gt;&lt;a name="indexterm-252"&gt;&lt;/a&gt;A response contains data passed between a server and the client. All responses
implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletResponse.html"&gt;ServletResponse&lt;/a&gt; interface. This interface defines methods that allow you to:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-253"&gt;&lt;/a&gt;&lt;a name="indexterm-254"&gt;&lt;/a&gt;&lt;a name="indexterm-255"&gt;&lt;/a&gt;&lt;a name="indexterm-256"&gt;&lt;/a&gt;Retrieve an output stream to use to send data to the client. To send character data, use the &lt;a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html"&gt;PrintWriter&lt;/a&gt; returned by the response’s &lt;tt&gt;getWriter&lt;/tt&gt; method. To send binary data in a MIME body response, use the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletOutputStream.html"&gt;ServletOutputStream&lt;/a&gt; returned by &lt;tt&gt;getOutputStream&lt;/tt&gt;. To mix binary and text data (as in a multipart response), use a &lt;tt&gt;ServletOutputStream&lt;/tt&gt; and manage the character sections manually.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Indicate the content type (for example, &lt;tt&gt;text/html&lt;/tt&gt;) being returned by the response with the &lt;tt&gt;setContentType(String)&lt;/tt&gt;
method. This method must be called before the response is committed. A
registry of content type names is kept by the Internet Assigned Numbers
Authority (IANA) at &lt;a href="http://www.iana.org/assignments/media-types/"&gt;http://www.iana.org/assignments/media-types/&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-257"&gt;&lt;/a&gt;Indicate whether to buffer output with the &lt;tt&gt;setBufferSize(int)&lt;/tt&gt;
method. By default, any content written to the output stream is
immediately sent to the client. Buffering allows content to be written
before anything is actually sent back to the client, thus providing the
servlet with more time to set appropriate status codes and headers or
forward to another web resource. The method must be called before any
content is written or before the response is committed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set localization information such as locale and character encoding. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaxu.html"&gt;Chapter 15, Internationalizing and Localizing Web Applications&lt;/a&gt; for details.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-258"&gt;&lt;/a&gt;&lt;a name="indexterm-259"&gt;&lt;/a&gt;&lt;a name="indexterm-260"&gt;&lt;/a&gt;HTTP response objects, &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletResponse.html"&gt;HttpServletResponse&lt;/a&gt;, have fields representing HTTP headers such as the following:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Status codes, which are used to indicate the reason a request is not satisfied or that a request has been redirected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cookies, which are used to store application-specific
information at the client. Sometimes cookies are used to maintain an
identifier for tracking a user’s session (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagm.html#bnagr"&gt;Session Tracking&lt;/a&gt;).&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In Duke’s Bookstore, &lt;tt&gt;BookDetailsServlet&lt;/tt&gt; generates an HTML page that displays information about a
book that the servlet retrieves from a database. The servlet first sets response
headers: the content type of the response and the buffer size. The servlet
buffers the page content because the database access can generate an exception that
would cause forwarding to an error page. By buffering the response, the servlet
prevents the client from seeing a concatenation of part of a Duke’s Bookstore
page with the error page should an error occur. The &lt;tt&gt;doGet&lt;/tt&gt; method then retrieves
a &lt;tt&gt;PrintWriter&lt;/tt&gt; from the response.&lt;/p&gt;&lt;p&gt;To fill in the response, the servlet first dispatches the request to
&lt;tt&gt;BannerServlet&lt;/tt&gt;, which generates a common banner for all the servlets in the application.
This process is discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagi.html#bnagj"&gt;Including Other Resources in the Response&lt;/a&gt;. Then the servlet retrieves the book identifier
from a request parameter and uses the identifier to retrieve information about the
book from the bookstore database. Finally, the servlet generates HTML markup that describes
the book information and then commits the response to the client by calling
the &lt;tt&gt;close&lt;/tt&gt; method on the &lt;tt&gt;PrintWriter&lt;/tt&gt;.&lt;/p&gt;&lt;pre&gt;public class BookDetailsServlet extends HttpServlet {
     ...
     public void doGet (HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        ...
        // set headers before accessing the Writer
        response.setContentType("text/html");
        response.setBufferSize(8192);
        PrintWriter out = response.getWriter();

        // then write the response
        out.println("&amp;lt;html&amp;gt;" +
            "&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;+
            messages.getString("TitleBookDescription")
            +&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;");

        // Get the dispatcher; it gets the banner to the user
        RequestDispatcher dispatcher =
            getServletContext().
            getRequestDispatcher("/banner");
        if (dispatcher != null)
            dispatcher.include(request, response);

        // Get the identifier of the book to display
        String bookId = request.getParameter("bookId");
        if (bookId != null) {
            // and the information about the book
            try {
                Book bd =
                    bookDB.getBook(bookId);
                ...
                // Print the information obtained
                out.println("&amp;lt;h2&amp;gt;" + bd.getTitle() + "&amp;lt;/h2&amp;gt;" +
                ...
            } catch (BookNotFoundException ex) {
                response.resetBuffer();
                throw new ServletException(ex);
            }
        }
        out.println("&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;");
        out.close();
    }
}&lt;/pre&gt;&lt;p&gt;&lt;tt&gt;BookDetailsServlet&lt;/tt&gt; generates a page that looks like &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html#bnaga"&gt;Figure 4-2&lt;/a&gt;.&lt;/p&gt;&lt;a name="bnaga"&gt;&lt;/a&gt;&lt;h6&gt;Figure 4-2 Book Details&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-bookDetails.gif" alt="Screen capture of book details. Shows " web="" servers="" for="" fun="" profit="" author,="" review,="" price,="" with="" links="" add="" to="" cart="" and="" continue="" shopping.="" height="657" width="662"&gt;</description>
		</newsitem>
		<newsitem id="33161818589" hide="0">
			<date>January  20, 2008</date>
			<title>Filtering Requests and Responses</title>
			<description>&lt;p&gt;A &lt;b&gt;filter&lt;/b&gt; is an object that can transform the header and content (or
both) of a request or response. Filters differ from web components in that
filters usually do not themselves create a response. Instead, a filter provides functionality that
can be “attached” to any kind of web resource. Consequently, a filter should
not have any dependencies on a web resource for which it is acting
as a filter; this way it can be composed with more than
one type of web resource. &lt;/p&gt;&lt;p&gt;The main tasks that a filter can perform are as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Query the request and act accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Block the request-and-response pair from passing any further.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modify the request headers and data. You do this by providing a customized version of the request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modify the response headers and data. You do this by providing a customized version of the response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interact with external resources.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Applications of filters include authentication, logging, image conversion, data compression, encryption, tokenizing streams,
XML transformations, and so on.&lt;/p&gt;&lt;p&gt;You can configure a web resource to be filtered by a chain
of zero, one, or more filters in a specific order. This chain is
specified when the web application containing the component is deployed and is instantiated
when a web container loads the component.&lt;/p&gt;&lt;p&gt;In summary, the tasks involved in using filters are&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Programming the filter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Programming customized requests and responses&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specifying the filter chain for each web resource&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnagc"&gt;&lt;/a&gt;&lt;h4&gt;Programming Filters&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-262"&gt;&lt;/a&gt;&lt;a name="indexterm-263"&gt;&lt;/a&gt;&lt;a name="indexterm-264"&gt;&lt;/a&gt;&lt;a name="indexterm-265"&gt;&lt;/a&gt;The filtering API is defined by the &lt;tt&gt;Filter&lt;/tt&gt;, &lt;tt&gt;FilterChain&lt;/tt&gt;, and &lt;tt&gt;FilterConfig&lt;/tt&gt; interfaces in the
&lt;tt&gt;javax.servlet&lt;/tt&gt; package. You define a filter by implementing the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/Filter.html"&gt;Filter&lt;/a&gt; interface. &lt;/p&gt;&lt;p&gt;The most important method in this interface is &lt;tt&gt;doFilter&lt;/tt&gt;, which is passed request,
response, and filter chain objects. This method can perform the following actions:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Examine the request headers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customize the request object if the filter wishes to modify request headers or data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customize the response object if the filter wishes to modify response headers or data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Invoke the next entity in the filter chain. If the current
filter is the last filter in the chain that ends with the target web
component or static resource, the next entity is the resource at the
end of the chain; otherwise, it is the next filter that was configured
in the WAR. The filter invokes the next entity by calling the &lt;tt&gt;doFilter&lt;/tt&gt;
method on the chain object (passing in the request and response it was
called with, or the wrapped versions it may have created).
Alternatively, it can choose to block the request by not making the
call to invoke the next entity. In the latter case, the filter is
responsible for filling out the response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Examine response headers after it has invoked the next filter in the chain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Throw an exception to indicate an error in processing.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-266"&gt;&lt;/a&gt;In addition to &lt;tt&gt;doFilter&lt;/tt&gt;, you must implement the &lt;tt&gt;init&lt;/tt&gt; and &lt;tt&gt;destroy&lt;/tt&gt; methods. The
&lt;tt&gt;init&lt;/tt&gt; method is called by the container when the filter is instantiated. If
you wish to pass initialization parameters to the filter, you retrieve them from
the &lt;tt&gt;FilterConfig&lt;/tt&gt; object passed to &lt;tt&gt;init&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;The Duke’s Bookstore application uses the filters &lt;tt&gt;HitCounterFilter&lt;/tt&gt; and &lt;tt&gt;OrderFilter&lt;/tt&gt;, located at
&lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore1/src/java/com/sun/bookstore1/filters/&lt;/tt&gt;, to increment and log the value of counters when the entry
and receipt servlets are accessed.&lt;/p&gt;&lt;p&gt;In the &lt;tt&gt;doFilter&lt;/tt&gt; method, both filters retrieve the servlet context from the filter
configuration object so that they can access the counters stored as context attributes.
After the filters have completed application-specific processing, they invoke &lt;tt&gt;doFilter&lt;/tt&gt; on the filter chain
object passed into the original &lt;tt&gt;doFilter&lt;/tt&gt; method. The elided code is discussed in
the next section.&lt;/p&gt;&lt;pre&gt;public final class HitCounterFilter implements Filter {
    private FilterConfig filterConfig = null;

    public void init(FilterConfig filterConfig)
         throws ServletException {
        this.filterConfig = filterConfig;
    }
    public void destroy() {
        this.filterConfig = null;
    }
    public void doFilter(ServletRequest request,
        ServletResponse response, FilterChain chain)
         throws IOException, ServletException {
        if (filterConfig == null)
            return;
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);
        Counter counter = (Counter)filterConfig.
            getServletContext().
            getAttribute("hitCounter");
        writer.println();
        writer.println("===============");
        writer.println("The number of hits is: " +
            counter.incCounter());
        writer.println("===============");
        // Log the resulting string
        writer.flush();
        System.out.println(sw.getBuffer().toString());
        ...
        chain.doFilter(request, wrapper);
        ...
    }
}&lt;/pre&gt;

&lt;a name="bnagd"&gt;&lt;/a&gt;&lt;h4&gt;Programming Customized Requests and Responses&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-267"&gt;&lt;/a&gt;&lt;a name="indexterm-268"&gt;&lt;/a&gt;There are many ways for a filter to modify a request or
response. For example, a filter can add an attribute to the request or
can insert data in the response. In the Duke’s Bookstore example, &lt;tt&gt;HitCounterFilter&lt;/tt&gt; inserts
the value of the counter into the response.&lt;/p&gt;&lt;p&gt;A filter that modifies a response must usually capture the response before it
is returned to the client. To do this, you pass a stand-in
stream to the servlet that generates the response. The stand-in stream prevents the servlet
from closing the original response stream when it completes and allows the filter
to modify the servlet’s response.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-269"&gt;&lt;/a&gt;To pass this stand-in stream to the servlet, the filter creates a response
wrapper that overrides the &lt;tt&gt;getWriter&lt;/tt&gt; or &lt;tt&gt;getOutputStream&lt;/tt&gt; method to return this stand-in
stream. The wrapper is passed to the &lt;tt&gt;doFilter&lt;/tt&gt; method of the filter chain.
Wrapper methods default to calling through to the wrapped request or response object.
This approach follows the well-known Wrapper or Decorator pattern described in &lt;b&gt;Design Patterns, Elements of Reusable Object-Oriented Software&lt;/b&gt;, by Erich
Gamma et al. (Addison-Wesley, 1995). The following sections describe how the hit counter
filter described earlier and other types of filters use wrappers.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-270"&gt;&lt;/a&gt;&lt;a name="indexterm-271"&gt;&lt;/a&gt;To override request methods, you wrap the request in an object that extends
&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestWrapper.html"&gt;ServletRequestWrapper&lt;/a&gt; or &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequestWrapper.html"&gt;HttpServletRequestWrapper&lt;/a&gt;. To override response methods, you wrap the response in an
object that extends &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletResponseWrapper.html"&gt;ServletResponseWrapper&lt;/a&gt; or &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletResponseWrapper.html"&gt;HttpServletResponseWrapper&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;tt&gt;HitCounterFilter&lt;/tt&gt; wraps the response in a &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore1/src/java/com/sun/bookstore1/filters/CharResponseWrapper&lt;/tt&gt;. The wrapped response is passed
to the next object in the filter chain, which is &lt;tt&gt;BookStoreServlet&lt;/tt&gt;. Then &lt;tt&gt;BookStoreServlet&lt;/tt&gt;
writes its response into the stream created by &lt;tt&gt;CharResponseWrapper&lt;/tt&gt;. When &lt;tt&gt;chain.doFilter&lt;/tt&gt; returns,
&lt;tt&gt;HitCounterFilter&lt;/tt&gt; retrieves the servlet’s response from &lt;tt&gt;PrintWriter&lt;/tt&gt; and writes it to a buffer.
The filter inserts the value of the counter into the buffer, resets the
content length header of the response, and then writes the contents of the
buffer to the response stream.&lt;/p&gt;&lt;pre&gt;PrintWriter out = response.getWriter();
CharResponseWrapper wrapper = new CharResponseWrapper(
    (HttpServletResponse)response);
chain.doFilter(request, wrapper);
CharArrayWriter caw = new CharArrayWriter();
caw.write(wrapper.toString().substring(0,
    wrapper.toString().indexOf("&amp;lt;/body&amp;gt;")-1));
caw.write("&amp;lt;p&amp;gt;\n&amp;lt;center&amp;gt;" +
     messages.getString("Visitor") + "&amp;lt;font color=’red’&amp;gt;" +
     counter.getCounter() + "&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;");
caw.write("\n&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;");
response.setContentLength(caw.toString().getBytes().length);
out.write(caw.toString());
out.close();

public class CharResponseWrapper extends
    HttpServletResponseWrapper {
    private CharArrayWriter output;
    public String toString() {
        return output.toString();
    }
    public CharResponseWrapper(HttpServletResponse response){
        super(response);
        output = new CharArrayWriter();
    }
    public PrintWriter getWriter(){
        return new PrintWriter(output);
    }
}&lt;/pre&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagb.html#bnage"&gt;Figure 4-3&lt;/a&gt; shows the entry page for Duke’s Bookstore with the hit counter.&lt;/p&gt;&lt;a name="bnage"&gt;&lt;/a&gt;&lt;h6&gt;Figure 4-3 Duke’s Bookstore with Hit Counter&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-dukesBookstore.gif" alt="Screen capture of Duke&amp;#8216;s Bookstore with " components="" for="" web="" developers="" recommendation,="" start="" shopping="" link="" and="" you="" are="" visitor="" number="" 2.="" height="627" width="662"&gt;

&lt;a name="bnagf"&gt;&lt;/a&gt;&lt;h4&gt;Specifying Filter Mappings&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-272"&gt;&lt;/a&gt;&lt;a name="indexterm-273"&gt;&lt;/a&gt;&lt;a name="indexterm-274"&gt;&lt;/a&gt;&lt;a name="indexterm-275"&gt;&lt;/a&gt;A web container uses filter mappings to decide how to apply filters to
web resources. A filter mapping matches a filter to a web component by
name, or to web resources by URL pattern. The filters are invoked in
the order in which filter mappings appear in the filter mapping list of
a WAR. You specify a filter mapping list for a WAR in its
deployment descriptor, either with NetBeans IDE or by coding the list by hand
with XML.&lt;/p&gt;&lt;p&gt;To declare the filter and map it to a web resource using
NetBeans IDE, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the application’s project node in the Project pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Web Pages and WEB-INF nodes under the project node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Filters at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Servlet Filters node in the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Add Filter Element to map the filter to a web resource by name or by URL pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Add Servlet Filter dialog, enter the name of the filter in the Filter Name field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Browse to locate the servlet class to which the filter
applies. You can include wildcard characters so that you can apply the
filter to more than one servlet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click OK.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To constrain how the filter is applied to requests, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the Filter Mappings node in the Filters tab of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the filter from the list of filters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Add.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Add Filter Mapping dialog, select one of the following dispatcher types:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;REQUEST&lt;/tt&gt;: Only when the request comes directly from the client&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;FORWARD&lt;/tt&gt;: Only when the request has been forwarded to a component (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagi.html#bnagk"&gt;Transferring Control to Another Web Component&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;INCLUDE&lt;/tt&gt;: Only when the request is being processed by a component that has been included (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagi.html#bnagj"&gt;Including Other Resources in the Response&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;ERROR&lt;/tt&gt;: Only when the request is being processed with the error page mechanism (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafi.html#bnafn"&gt;Handling Servlet Errors&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;You
can direct the filter to be applied to any combination of the preceding
situations by selecting multiple dispatcher types. If no types are
specified, the default option is &lt;tt&gt;REQUEST&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;You can declare, map, and constrain the filter by editing the XML
in the web application deployment descriptor directly by following these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;While in the &lt;tt&gt;web.xml&lt;/tt&gt; editor pane in NetBeans IDE, click XML at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Declare the filter by adding a &lt;tt&gt;filter&lt;/tt&gt; element right after the &lt;tt&gt;display-name&lt;/tt&gt; element. The &lt;tt&gt;filter&lt;/tt&gt; element creates a name for the filter and declares the filter’s implementation class and initialization parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Map the filter to a web resource by name or by URL pattern using the &lt;tt&gt;filter-mapping&lt;/tt&gt; element:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Include a &lt;tt&gt;filter-name&lt;/tt&gt; element that specifies the name of the filter as defined by the &lt;tt&gt;filter&lt;/tt&gt; element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include a &lt;tt&gt;servlet-name&lt;/tt&gt; element that specifies to which servlet the filter applies. The &lt;tt&gt;servlet-name&lt;/tt&gt; element can include wildcard characters so that you can apply the filter to more than one servlet.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Constrain how the filter will be applied to requests by
specifying one of the enumerated dispatcher options (described in step
4 of the preceding set of steps) with the &lt;tt&gt;dispatcher&lt;/tt&gt; element and adding the &lt;tt&gt;dispatcher&lt;/tt&gt; element to the &lt;tt&gt;filter-mapping&lt;/tt&gt; element.&lt;/p&gt;&lt;p&gt;You can direct the filter to be applied to any combination of the preceding situations by including multiple &lt;tt&gt;dispatcher&lt;/tt&gt; elements. If no elements are specified, the default option is &lt;tt&gt;REQUEST&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;If you want to log every request to a web application, you
map the hit counter filter to the URL pattern &lt;tt&gt;/*&lt;/tt&gt;. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagb.html#bnagg"&gt;Table 4-6&lt;/a&gt; summarizes the
filter definition and mapping list for the Duke’s Bookstore application. The filters are
matched by servlet name, and each filter chain contains only one filter.&lt;/p&gt;&lt;a name="bnagg"&gt;&lt;/a&gt;&lt;h6&gt;Table 4-6 Duke’s Bookstore Filter Definition and Mapping List&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="90*"&gt;&lt;col width="144*"&gt;&lt;col width="106*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Filter&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Class&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Servlet&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;HitCounterFilter&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;filters.HitCounterFilter&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;BookStoreServlet&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;OrderFilter&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;filters.OrderFilter&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ReceiptServlet&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a name="indexterm-276"&gt;&lt;/a&gt;&lt;a name="indexterm-277"&gt;&lt;/a&gt;You can map a filter to one or more web resources and you
can map more than one filter to a web resource. This is illustrated
in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagb.html#bnagh"&gt;Figure 4-4&lt;/a&gt;, where filter F1 is mapped to servlets S1, S2, and S3,
filter F2 is mapped to servlet S2, and filter F3 is mapped to
servlets S1 and S2.&lt;/p&gt;&lt;a name="bnagh"&gt;&lt;/a&gt;&lt;h6&gt;Figure 4-4 Filter-to-Servlet Mapping&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-filterMapping.gif" alt="Diagram of filter-to-servlet mapping with filters F1-F3 and servlets S1-S3. F1 filters S1-S3, then F2 filters S2, then F3 filters S1 and S2."&gt;&lt;p&gt;&lt;a name="indexterm-278"&gt;&lt;/a&gt;&lt;a name="indexterm-279"&gt;&lt;/a&gt;Recall that a filter chain is one of the objects passed to the
&lt;tt&gt;doFilter&lt;/tt&gt; method of a filter. This chain is formed indirectly by means of
filter mappings. The order of the filters in the chain is the same
as the order in which filter mappings appear in the web application deployment
descriptor.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-280"&gt;&lt;/a&gt;&lt;a name="indexterm-281"&gt;&lt;/a&gt;When a filter is mapped to servlet S1, the web container invokes the
&lt;tt&gt;doFilter&lt;/tt&gt; method of F1. The &lt;tt&gt;doFilter&lt;/tt&gt; method of each filter in S1’s
filter chain is invoked by the preceding filter in the chain by means
of the &lt;tt&gt;chain.doFilter&lt;/tt&gt; method. Because S1’s filter chain contains filters F1 and F3,
F1’s call to &lt;tt&gt;chain.doFilter&lt;/tt&gt; invokes the &lt;tt&gt;doFilter&lt;/tt&gt; method of filter F3. When F3’s &lt;tt&gt;doFilter&lt;/tt&gt;
method completes, control returns to F1’s &lt;tt&gt;doFilter&lt;/tt&gt; method.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="45700547695" hide="0">
			<date>January  20, 2008</date>
			<title>Invoking Other Web Resources</title>
			<description>&lt;p&gt;Web components can invoke other web resources in two ways: indirectly and directly.
A web component indirectly invokes another web resource when it embeds a URL
that points to another web component in content returned to a client. In
the Duke’s Bookstore application, most web components contain embedded URLs that point to
other web components. For example, &lt;tt&gt;ShowCartServlet&lt;/tt&gt; indirectly invokes the &lt;tt&gt;CatalogServlet&lt;/tt&gt; through the following
embedded URL:&lt;/p&gt;&lt;pre&gt;/bookstore1/catalog&lt;/pre&gt;&lt;p&gt;A web component can also directly invoke another resource while it is executing.
There are two possibilities: The web component can include the content of another
resource, or it can forward a request to another resource.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-283"&gt;&lt;/a&gt;&lt;a name="indexterm-284"&gt;&lt;/a&gt;To invoke a resource available on the server that is running a web
component, you must first obtain a &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/RequestDispatcher.html"&gt;RequestDispatcher&lt;/a&gt; object using the &lt;tt&gt;getRequestDispatcher("URL")&lt;/tt&gt; method.&lt;/p&gt;&lt;p&gt;You can get a &lt;tt&gt;RequestDispatcher&lt;/tt&gt; object from either a request or the web
context; however, the two methods have slightly different behavior. The method takes the
path to the requested resource as an argument. A request can take a
relative path (that is, one that does not begin with a &lt;tt&gt;/&lt;/tt&gt;), but
the web context requires an absolute path. If the resource is not available
or if the server has not implemented a &lt;tt&gt;RequestDispatcher&lt;/tt&gt; object for that
type of resource, &lt;tt&gt;getRequestDispatcher&lt;/tt&gt; will return null. Your servlet should be prepared to
deal with this condition.&lt;/p&gt;

&lt;a name="bnagj"&gt;&lt;/a&gt;&lt;h4&gt;Including Other Resources in the Response&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-285"&gt;&lt;/a&gt;&lt;a name="indexterm-286"&gt;&lt;/a&gt;It is often useful to include another web resource (for example, banner content
or copyright information) in the response returned from a web component. To include
another resource, invoke the &lt;tt&gt;include&lt;/tt&gt; method of a &lt;tt&gt;RequestDispatcher&lt;/tt&gt; object:&lt;/p&gt;&lt;pre&gt;include(request, response);&lt;/pre&gt;&lt;p&gt;If the resource is static, the &lt;tt&gt;include&lt;/tt&gt; method enables programmatic server-side includes. If
the resource is a web component, the effect of the method is to
send the request to the included web component, execute the web component, and
then include the result of the execution in the response from the containing
servlet. An included web component has access to the request object, but it
is limited in what it can do with the response object:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;It can write to the body of the response and commit a response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It cannot set headers or call any method (for example, &lt;tt&gt;setCookie&lt;/tt&gt;) that affects the headers of the response.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The banner for the Duke’s Bookstore application is generated by &lt;tt&gt;BannerServlet&lt;/tt&gt;. Note
that both &lt;tt&gt;doGet&lt;/tt&gt; and &lt;tt&gt;doPost&lt;/tt&gt; are implemented because &lt;tt&gt;BannerServlet&lt;/tt&gt; can be dispatched from
either method in a calling servlet.&lt;/p&gt;&lt;pre&gt;public class BannerServlet extends HttpServlet {
     public void doGet (HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
            output(request, response);
    }
    public void doPost (HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
            output(request, response);
}

private void output(HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        out.println("&amp;lt;body bgcolor=\"#ffffff\"&amp;gt;" +
        "&amp;lt;center&amp;gt;" + "&amp;lt;hr&amp;gt; &amp;lt;br&amp;gt; &amp;amp;nbsp;" + "&amp;lt;h1&amp;gt;" +
        "&amp;lt;font size=\"+3\" color=\"#CC0066\"&amp;gt;Duke’s &amp;lt;/font&amp;gt;" +
        &amp;lt;img src=\"" + request.getContextPath() +
        "/duke.books.gif\"&amp;gt;" +
         "&amp;lt;font size=\"+3\" color=\"black\"&amp;gt;Bookstore&amp;lt;/font&amp;gt;" +
        "&amp;lt;/h1&amp;gt;" + "&amp;lt;/center&amp;gt;" + "&amp;lt;br&amp;gt; &amp;amp;nbsp; &amp;lt;hr&amp;gt; &amp;lt;br&amp;gt; ");
    }
}&lt;/pre&gt;&lt;p&gt;Each servlet in the Duke’s Bookstore application includes the result from &lt;tt&gt;BannerServlet&lt;/tt&gt; using
the following code:&lt;/p&gt;&lt;pre&gt;RequestDispatcher dispatcher =
    getServletContext().getRequestDispatcher("/banner");
if (dispatcher != null)
    dispatcher.include(request, response);
}&lt;/pre&gt;

&lt;a name="bnagk"&gt;&lt;/a&gt;&lt;h4&gt;Transferring Control to Another Web Component&lt;/h4&gt;
&lt;p&gt;In some applications, you might want to have one web component do
preliminary processing of a request and have another component generate the response. For example,
you might want to partially process a request and then transfer to another
component depending on the nature of the request.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-287"&gt;&lt;/a&gt;&lt;a name="indexterm-288"&gt;&lt;/a&gt;To transfer control to another web component, you invoke the &lt;tt&gt;forward&lt;/tt&gt; method of
a &lt;tt&gt;RequestDispatcher&lt;/tt&gt;. When a request is forwarded, the request URL is set to
the path of the forwarded page. The original URI and its constituent parts
are saved as request attributes &lt;tt&gt;javax.servlet.forward.[&lt;i&gt;request-uri&lt;/i&gt;|&lt;i&gt;context-path&lt;/i&gt;|&lt;i&gt;servlet-path&lt;/i&gt;|&lt;i&gt;path-info&lt;/i&gt;|&lt;i&gt;query-string&lt;/i&gt;]&lt;/tt&gt;. The &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/dispatcher/Dispatcher&lt;/tt&gt; servlet, used by a
version of the Duke’s Bookstore application described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnall.html"&gt;The Example JSP Pages&lt;/a&gt;, saves the path information from
the original URL, retrieves a &lt;tt&gt;RequestDispatcher&lt;/tt&gt; from the request, and then forwards
to the JSP page, &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore3/web/template/template.jsp&lt;/tt&gt;.&lt;/p&gt;&lt;pre&gt;public class Dispatcher extends HttpServlet {
    public void doGet(HttpServletRequest request,
         HttpServletResponse response) {
        RequestDispatcher dispatcher = request.
            getRequestDispatcher("/template.jsp");
        if (dispatcher != null)
            dispatcher.forward(request, response);
    }
    public void doPost(HttpServletRequest request,
     ...
}&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;forward&lt;/tt&gt; method should be used to give another resource responsibility for replying
to the user. If you have already accessed a &lt;tt&gt;ServletOutputStream&lt;/tt&gt; or &lt;tt&gt;PrintWriter&lt;/tt&gt; object within
the servlet, you cannot use this method; doing so throws an &lt;tt&gt;IllegalStateException&lt;/tt&gt;.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="38930331778" hide="0">
			<date>January  20, 2008</date>
			<title>Accessing the Web Context</title>
			<description>&lt;p&gt;The context in which web components execute is an object that implements the
&lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html"&gt;ServletContext&lt;/a&gt; interface. You retrieve the web context using the &lt;tt&gt;getServletContext&lt;/tt&gt; method. The web
context provides methods for accessing:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Initialization parameters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resources associated with the web context&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object-valued attributes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Logging capabilities&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The web context is used by the Duke’s Bookstore filters &lt;tt&gt;HitCounterFilter&lt;/tt&gt; and
&lt;tt&gt;OrderFilter&lt;/tt&gt;, which are discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagb.html"&gt;Filtering Requests and Responses&lt;/a&gt;. Each filter stores a counter as a
context attribute. Recall from &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafs"&gt;Controlling Concurrent Access to Shared Resources&lt;/a&gt; that the counter’s access methods are synchronized to
prevent incompatible operations by servlets that are running concurrently. A filter retrieves the
counter object using the context’s &lt;tt&gt;getAttribute&lt;/tt&gt; method. The incremented value of the counter is
recorded in the log.&lt;/p&gt;&lt;pre&gt;public final class HitCounterFilter implements Filter {
    private FilterConfig filterConfig = null;
    public void doFilter(ServletRequest request,
        ServletResponse response, FilterChain chain)
         throws IOException, ServletException {
        ...
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);
        ServletContext context = filterConfig.
            getServletContext();
        Counter counter = (Counter)context.
            getAttribute("hitCounter");
        ...
        writer.println("The number of hits is: " +
            counter.incCounter());
        ...
        System.out.println(sw.getBuffer().toString());
        ...
    }
}&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="25714283850" hide="0">
			<date>January  20, 2008</date>
			<title>Maintaining Client State</title>
			<description>&lt;p&gt;Many applications require that a series of requests from a client be associated
with one another. For example, the Duke’s Bookstore application saves the state of
a user’s shopping cart across requests. Web-based applications are responsible for maintaining such
state, called a &lt;b&gt;session&lt;/b&gt;, because HTTP is stateless. To support applications that
need to maintain state, Java Servlet technology provides an API for managing sessions and
allows several mechanisms for implementing sessions.&lt;/p&gt;

&lt;a name="bnagn"&gt;&lt;/a&gt;&lt;h4&gt;Accessing a Session&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-294"&gt;&lt;/a&gt;&lt;a name="indexterm-295"&gt;&lt;/a&gt;Sessions are represented by an &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html"&gt;HttpSession&lt;/a&gt; object. You access a session by
calling the &lt;tt&gt;getSession&lt;/tt&gt; method of a request object. This method returns the
current session associated with this request, or, if the request does not have
a session, it creates one.&lt;/p&gt;

&lt;a name="bnago"&gt;&lt;/a&gt;&lt;h4&gt;Associating Objects with a Session&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-296"&gt;&lt;/a&gt;You can associate object-valued attributes with a session by name. Such attributes are
accessible by any web component that belongs to the same web context &lt;b&gt;and&lt;/b&gt;
is handling a request that is part of the same session.&lt;/p&gt;&lt;p&gt;The Duke’s Bookstore application stores a customer’s shopping cart as a session attribute.
This allows the shopping cart to be saved between requests and also allows
cooperating servlets to access the cart. &lt;tt&gt;CatalogServlet&lt;/tt&gt; adds items to the cart;
&lt;tt&gt;ShowCartServlet&lt;/tt&gt; displays, deletes items from, and clears the cart; and &lt;tt&gt;CashierServlet&lt;/tt&gt; retrieves the total
cost of the books in the cart.&lt;/p&gt;&lt;pre&gt;public class CashierServlet extends HttpServlet {
     public void doGet (HttpServletRequest request,
        HttpServletResponse response)
        throws ServletException, IOException {

        // Get the user’s session and shopping cart
        HttpSession session = request.getSession();
        ShoppingCart cart =
            (ShoppingCart)session.
                getAttribute("cart");
         ...
        // Determine the total price of the user’s books
        double total = cart.getTotal();&lt;/pre&gt;

&lt;a name="bnagp"&gt;&lt;/a&gt;&lt;h5&gt;Notifying Objects That Are Associated with a Session&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-297"&gt;&lt;/a&gt;Recall that your application can notify web context and session listener objects of
servlet life-cycle events (&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafi.html#bnafj"&gt;Handling Servlet Life-Cycle Events&lt;/a&gt;). You can also notify objects of certain events related
to their association with a session such as the following:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;When the object is added to or removed from a session. To receive this notification, your object must implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionBindingListener.html"&gt;javax.servlet.http.HttpSessionBindingListener&lt;/a&gt; interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the session to which the object is attached will be
passivated or activated. A session will be passivated or activated when
it is moved between virtual machines or saved to and restored from
persistent storage. To receive this notification, your object must
implement the &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionActivationListener.html"&gt;javax.servlet.http.HttpSessionActivationListener&lt;/a&gt; interface.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnagq"&gt;&lt;/a&gt;&lt;h4&gt;Session Management&lt;/h4&gt;
&lt;p&gt;Because there is no way for an HTTP client to signal that
it no longer needs a session, each session has an associated timeout so
that its resources can be reclaimed. The timeout period can be accessed by
using a session’s &lt;tt&gt;[get|set]MaxInactiveInterval&lt;/tt&gt; methods. &lt;/p&gt;&lt;p&gt;You can also set the timeout period in the deployment descriptor using
NetBeans IDE:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Open the &lt;tt&gt;web.xml&lt;/tt&gt; file in the &lt;tt&gt;web.xml&lt;/tt&gt; editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click General at the top of the editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter an integer value in the Session Timeout field. The integer
value represents the number of minutes of inactivity that must pass
before the session times out.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To ensure that an active session is not timed out, you should
periodically access the session by using service methods because this resets the session’s time-to-live
counter.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-298"&gt;&lt;/a&gt;&lt;a name="indexterm-299"&gt;&lt;/a&gt;When a particular client interaction is finished, you use the session’s &lt;tt&gt;invalidate&lt;/tt&gt; method
to invalidate a session on the server side and remove any session data.
The bookstore application’s &lt;tt&gt;ReceiptServlet&lt;/tt&gt; is the last servlet to access a client’s
session, so it has the responsibility to invalidate the session:&lt;/p&gt;&lt;pre&gt;public class ReceiptServlet extends HttpServlet {
     public void doPost(HttpServletRequest request,
                    HttpServletResponse response)
                     throws ServletException, IOException {
        // Get the user’s session and shopping cart
        HttpSession session = request.getSession();
        // Payment received -- invalidate the session
        session.invalidate();
        ...&lt;/pre&gt;

&lt;a name="bnagr"&gt;&lt;/a&gt;&lt;h4&gt;Session Tracking&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-300"&gt;&lt;/a&gt;A web container can use several methods to associate a session with a
user, all of which involve passing an identifier between the client and the
server. The identifier can be maintained on the client as a cookie, or
the web component can include the identifier in every URL that is
returned to the client.&lt;/p&gt;&lt;p&gt;If your application uses session objects, you must ensure that session tracking is
enabled by having the application rewrite URLs whenever the client turns off cookies.
You do this by calling the response’s &lt;tt&gt;encodeURL(URL)&lt;/tt&gt; method on all URLs
returned by a servlet. This method includes the session ID in the URL
only if cookies are disabled; otherwise, it returns the URL unchanged.&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;doGet&lt;/tt&gt; method of &lt;tt&gt;ShowCartServlet&lt;/tt&gt; encodes the three URLs at the bottom of
the shopping cart display page as follows:&lt;/p&gt;&lt;pre&gt;out.println("&amp;lt;p&amp;gt; &amp;amp;nbsp; &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;a href=\"" +
    response.encodeURL(request.getContextPath() +
        "/bookcatalog") +
        "\"&amp;gt;" + messages.getString("ContinueShopping") +
        "&amp;lt;/a&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;" +
        "&amp;lt;a href=\"" +
    response.encodeURL(request.getContextPath() +
        "/bookcashier") +
        "\"&amp;gt;" + messages.getString("Checkout") +
        "&amp;lt;/a&amp;gt; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;" +
        "&amp;lt;a href=\"" +
     response.encodeURL(request.getContextPath() +
        "/bookshowcart?Clear=clear") +
        "\"&amp;gt;" + messages.getString("ClearCart") +
        "&amp;lt;/a&amp;gt;&amp;lt;/strong&amp;gt;");&lt;/pre&gt;&lt;p&gt;If cookies are turned off, the session is encoded in the Check
Out URL as follows:&lt;/p&gt;&lt;pre&gt;http://localhost:8080/bookstore1/cashier;jsessionid=c0o7fszeb1&lt;/pre&gt;&lt;p&gt;If cookies are turned on, the URL is simply&lt;/p&gt;&lt;pre&gt;http://localhost:8080/bookstore1/cashier&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="39578324488" hide="0">
			<date>January  20, 2008</date>
			<title>Finalizing a Servlet</title>
			<description>&lt;p&gt;When a servlet container determines that a servlet should be removed from 
	service (for example, when a container wants to reclaim memory resources or 
	when it is being shut down), the container calls the &lt;tt&gt;destroy&lt;/tt&gt; method of 
	the &lt;tt&gt;Servlet&lt;/tt&gt; interface. In this method, you release any resources the 
	servlet is using and save any persistent state. The following &lt;tt&gt;destroy&lt;/tt&gt; method 
	releases the database object created in the &lt;tt&gt;init&lt;/tt&gt; method described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafu.html"&gt;
		Initializing a Servlet&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;public void destroy() {
    bookDB = null;
}&lt;/pre&gt;
&lt;p&gt;All of a servlet’s service methods should be complete when a servlet is removed. 
	The server tries to ensure this by calling the &lt;tt&gt;destroy&lt;/tt&gt; method only 
	after all service requests have returned or after a server-specific grace 
	period, whichever comes first. If your servlet has operations that take a long 
	time to run (that is, operations that may run longer than the server’s grace 
	period), the operations could still be running when &lt;tt&gt;destroy&lt;/tt&gt; is called. 
	You must make sure that any threads still handling client requests complete; 
	the remainder of this section describes how to do the following:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
		&lt;p&gt;Keep track of how many threads are currently running the &lt;tt&gt;service&lt;/tt&gt; method.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Provide a clean shutdown by having the &lt;tt&gt;destroy&lt;/tt&gt; method notify 
			long-running threads of the shutdown and wait for them to complete.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;p&gt;Have the long-running methods poll periodically to check for shutdown and, if 
			necessary, stop working, clean up, and return.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="bnagt"&gt;&lt;/a&gt;
&lt;h4&gt;Tracking Service Requests&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-303"&gt;&lt;/a&gt;To track service requests, include in your servlet 
	class a field that counts the number of service methods that are running. The 
	field should have synchronized access methods to increment, decrement, and 
	return its value.&lt;/p&gt;
&lt;pre&gt;public class ShutdownExample extends HttpServlet {
    private int serviceCounter = 0;
    ...
    // Access methods for serviceCounter
    protected synchronized void enteringServiceMethod() {
        serviceCounter++;
    }
    protected synchronized void leavingServiceMethod() {
        serviceCounter--;
    }
    protected synchronized int numServices() {
        return serviceCounter;
    }
}&lt;/pre&gt;
&lt;p&gt;The &lt;tt&gt;service&lt;/tt&gt; method should increment the service counter each time the 
	method is entered and should decrement the counter each time the method 
	returns. This is one of the few times that your &lt;tt&gt;HttpServlet&lt;/tt&gt; subclass 
	should override the &lt;tt&gt;service&lt;/tt&gt; method. The new method should call &lt;tt&gt;super.service&lt;/tt&gt;
	to preserve the functionality of the original &lt;tt&gt;service&lt;/tt&gt; method:&lt;/p&gt;
&lt;pre&gt;protected void service(HttpServletRequest req,
                    HttpServletResponse resp)
                    throws ServletException,IOException {
    enteringServiceMethod();
    try {
        super.service(req, resp);
    } finally {
        leavingServiceMethod();
    }
}&lt;/pre&gt;
&lt;a name="bnagu"&gt;&lt;/a&gt;
&lt;h4&gt;Notifying Methods to Shut Down&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-304"&gt;&lt;/a&gt;To ensure a clean shutdown, your &lt;tt&gt;destroy&lt;/tt&gt; method 
	should not release any shared resources until all the service requests have 
	completed. One part of doing this is to check the service counter. Another part 
	is to notify the long-running methods that it is time to shut down. For this 
	notification, another field is required. The field should have the usual access 
	methods:&lt;/p&gt;
&lt;pre&gt;public class ShutdownExample extends HttpServlet {
    private boolean shuttingDown;
    ...
    //Access methods for shuttingDown
    protected synchronized void setShuttingDown(boolean flag) {
        shuttingDown = flag;
    }
    protected synchronized boolean isShuttingDown() {
        return shuttingDown;
    }
}&lt;/pre&gt;
&lt;p&gt;Here is an example of the &lt;tt&gt;destroy&lt;/tt&gt; method using these fields to provide 
	a clean shutdown:&lt;/p&gt;
&lt;pre&gt;public void destroy() {
    /* Check to see whether there are still service methods /*
    /* running, and if there are, tell them to stop. */
    if (numServices() &amp;gt; 0) {
        setShuttingDown(true);
    }

    /* Wait for the service methods to stop. */
    while(numServices() &amp;gt; 0) {
        try {
            Thread.sleep(interval);
        } catch (InterruptedException e) {
        }
    }
}&lt;/pre&gt;
&lt;a name="bnagv"&gt;&lt;/a&gt;
&lt;h4&gt;Creating Polite Long-Running Methods&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-305"&gt;&lt;/a&gt;The final step in providing a clean shutdown is to 
	make any long-running methods behave politely. Methods that might run for a 
	long time should check the value of the field that notifies them of shutdowns 
	and should interrupt their work, if necessary.&lt;/p&gt;
&lt;pre&gt;public void doPost(...) {
    ...
    for(i = 0; ((i &amp;lt; lotsOfStuffToDo) &amp;amp;&amp;amp;
         !isShuttingDown()); i++) {
        try {
            partOfLongRunningOperation(i);
        } catch (InterruptedException e) {
            ...
        }
    }
}&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="48987283522" hide="0">
			<date>January  20, 2008</date>
			<title>JavaServer Pages Technology</title>
			<description>&lt;p&gt;JavaServer Pages (JSP) technology allows you to easily create web content that has
both static and dynamic components. JSP technology makes available all the dynamic capabilities
of Java Servlet technology but provides a more natural approach to creating static
content. &lt;/p&gt;&lt;p&gt;The main features of JSP technology are as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A language for developing JSP pages, which are text-based
documents that describe how to process a request and construct a
response&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An expression language for accessing server-side objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mechanisms for defining extensions to the JSP language&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;JSP technology also contains an API that is used by developers of
web containers, but this API is not covered in this tutorial.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="44024696421" hide="0">
			<date>January  20, 2008</date>
			<title>What Is a JSP Page?</title>
			<description>&lt;p&gt;A &lt;b&gt;JSP page&lt;/b&gt; is a text document that contains two types of text: static
data, which can be expressed in any text-based format (such as &lt;a href="http://www.w3.org/MarkUp/"&gt;HTML&lt;/a&gt;, &lt;a href="http://www.w3.org/TR/SVG"&gt;SVG&lt;/a&gt;,
&lt;a href="http://xml.coverpages.org/wap-wml.html"&gt;WML&lt;/a&gt;, and &lt;a href="http://www.w3.org/TR/REC-xml/"&gt;XML&lt;/a&gt;), and JSP elements, which construct dynamic content.&lt;/p&gt;&lt;p&gt;The recommended file extension for the source file of a JSP page
is &lt;tt&gt;.jsp&lt;/tt&gt;. The page can be composed of a top file that
includes other files that contain either a complete JSP page or a fragment
of a JSP page. The recommended extension for the source file of a
fragment of a JSP page is &lt;tt&gt;.jspf&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-309"&gt;&lt;/a&gt;&lt;a name="indexterm-310"&gt;&lt;/a&gt;The JSP elements in a JSP page can be expressed in two
syntaxes, standard and XML, though any given file can use only one syntax.
A JSP page in XML syntax is an XML document and can be
manipulated by tools and APIs for XML documents. This chapter and Chapters &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnakc.html"&gt;Chapter 7, JavaServer Pages Standard Tag Library&lt;/a&gt;
through &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaon.html"&gt;Chapter 9, Scripting in JSP Pages&lt;/a&gt; document only the standard syntax. The XML syntax is covered in
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajo.html"&gt;Chapter 6, JavaServer Pages Documents&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnagz"&gt;&lt;/a&gt;&lt;h4&gt;A Simple JSP Page Example&lt;/h4&gt;
&lt;p&gt;The web page in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagy.html#bnaha"&gt;Figure 5-1&lt;/a&gt; is a form that allows you to select
a locale and displays the date in a manner appropriate to the locale.&lt;/p&gt;&lt;a name="bnaha"&gt;&lt;/a&gt;&lt;h6&gt;Figure 5-1 Localized Date Form&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-dateForm.gif" alt="Screen capture of localized date form. Locale drop-down shows Lithuanian. Get Date button displays the date, " antradienis,="" 2004,="" kovo="" 16.="" height="237" width="662"&gt;&lt;p&gt;&lt;a name="indexterm-311"&gt;&lt;/a&gt;The source code for this example is in the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/date/&lt;/tt&gt; directory. The
JSP page, &lt;tt&gt;index.jsp&lt;/tt&gt;, appears below; it is a typical mixture of static HTML
markup and JSP elements. If you have developed web pages, you are probably
familiar with the HTML document structure statements (&lt;tt&gt;&amp;lt;head&amp;gt;&lt;/tt&gt;, &lt;tt&gt;&amp;lt;body&amp;gt;&lt;/tt&gt;, and so on) and the
HTML statements that create a form (&lt;tt&gt;&amp;lt;form&amp;gt;&lt;/tt&gt;) and a menu (&lt;tt&gt;&amp;lt;select&amp;gt;&lt;/tt&gt;).&lt;/p&gt;&lt;p&gt;The lines in bold in the example code contain the following types
of JSP constructs:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A page directive (&lt;tt&gt;&lt;b&gt;&amp;lt;%@page ... %&amp;gt;&lt;/b&gt;&lt;/tt&gt;) sets the content type returned by the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tag library directives (&lt;tt&gt;&lt;b&gt;&amp;lt;%@taglib ... %&amp;gt;&lt;/b&gt;&lt;/tt&gt;) import custom tag libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;&lt;b&gt;jsp:useBean&lt;/b&gt;&lt;/tt&gt; is a standard element that creates
an object containing a collection of locales and initializes an
identifier that points to that object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JSP expression language expressions (&lt;tt&gt;&lt;b&gt;${ }&lt;/b&gt;&lt;/tt&gt;) retrieve the value of object properties. The values are used to set custom tag attribute values and create dynamic content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom tags (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;) set a variable (&lt;tt&gt;&lt;b&gt;c:set&lt;/b&gt;&lt;/tt&gt;), iterate over a collection of locale names (&lt;tt&gt;&lt;b&gt;c:forEach&lt;/b&gt;&lt;/tt&gt;), and conditionally insert HTML text into the response (&lt;tt&gt;&lt;b&gt;c:if&lt;/b&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;b&gt;c:choose&lt;/b&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;b&gt;c:when&lt;/b&gt;&lt;/tt&gt;, &lt;tt&gt;&lt;b&gt;c:otherwise&lt;/b&gt;&lt;/tt&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;&lt;b&gt;jsp:setProperty&lt;/b&gt;&lt;/tt&gt; is another standard element that sets the value of an object property.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A function (&lt;tt&gt;&lt;b&gt;f:equals&lt;/b&gt;&lt;/tt&gt;) tests the equality of an attribute and the current item of a collection. (A built-in &lt;tt&gt;==&lt;/tt&gt; operator is usually used to test equality.)&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Here is the JSP page:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ &lt;b&gt;page contentType&lt;/b&gt;="text/html; charset=UTF-8" %&amp;gt;
&amp;lt;%@ &lt;b&gt;taglib&lt;/b&gt; uri="http://java.sun.com/jsp/jstl/core
"
         prefix="c" %&amp;gt;
&amp;lt;%@ &lt;b&gt;taglib&lt;/b&gt; uri="/functions" prefix="f" %&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Localized Dates&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;body bgcolor="white"&amp;gt;
&amp;lt;&lt;b&gt;jsp:useBean&lt;/b&gt; id="locales" scope="application"
    class="mypkg.MyLocales"/&amp;gt;

&amp;lt;form name="localeForm" action="index.jsp" method="post"&amp;gt;
&amp;lt;&lt;b&gt;c:set&lt;/b&gt; var="selectedLocaleString" value="&lt;b&gt;${param.locale}&lt;/b&gt;" /&amp;gt;
&amp;lt;&lt;b&gt;c:set&lt;/b&gt; var="selectedFlag"
     value="&lt;b&gt;${!empty selectedLocaleString}&lt;/b&gt;" /&amp;gt;
&amp;lt;b&amp;gt;Locale:&amp;lt;/b&amp;gt;
&amp;lt;select name=locale&amp;gt;
&amp;lt;&lt;b&gt;c:forEach&lt;/b&gt; var="localeString" items="&lt;b&gt;${locales.localeNames}&lt;/b&gt;" &amp;gt;
&amp;lt;&lt;b&gt;c:choose&lt;/b&gt;&amp;gt;
    &amp;lt;&lt;b&gt;c:when&lt;/b&gt; test="&lt;b&gt;${selectedFlag}&lt;/b&gt;"&amp;gt;
        &amp;lt;&lt;b&gt;c:choose&lt;/b&gt;&amp;gt;
            &amp;lt;&lt;b&gt;c:when&lt;/b&gt;
                 test="&lt;b&gt;${f:equals(selectedLocaleString, localeString)}&lt;/b&gt;" &amp;gt;
                &amp;lt;option selected&amp;gt;&lt;b&gt;${localeString}&lt;/b&gt;&amp;lt;/option&amp;gt;
            &amp;lt;/c:when&amp;gt;
            &amp;lt;c:otherwise&amp;gt;
                &amp;lt;option&amp;gt;&lt;b&gt;${localeString}&lt;/b&gt;&amp;lt;/option&amp;gt;
            &amp;lt;/c:otherwise&amp;gt;
        &amp;lt;/c:choose&amp;gt;
    &amp;lt;/c:when&amp;gt;
    &amp;lt;&lt;b&gt;c:otherwise&lt;/b&gt;&amp;gt;
        &amp;lt;option&amp;gt;&lt;b&gt;${localeString}&lt;/b&gt;&amp;lt;/option&amp;gt;
    &amp;lt;/c:otherwise&amp;gt;
&amp;lt;/c:choose&amp;gt;
&amp;lt;/c:forEach&amp;gt;
&amp;lt;/select&amp;gt;
&amp;lt;input type="submit" name="Submit" value="Get Date"&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;&lt;b&gt;c:if&lt;/b&gt; test="${selectedFlag}" &amp;gt;
    &amp;lt;&lt;b&gt;jsp:setProperty&lt;/b&gt; name="locales"
        property="selectedLocaleString"
        value="&lt;b&gt;${selectedLocaleString}&lt;/b&gt;" /&amp;gt;
    &amp;lt;&lt;b&gt;jsp:useBean&lt;/b&gt; id="date" class="mypkg.MyDate"/&amp;gt;
    &amp;lt;&lt;b&gt;jsp:setProperty&lt;/b&gt; name="date" property="locale"
        value="&lt;b&gt;${locales.selectedLocale}&lt;/b&gt;"/&amp;gt;
    &amp;lt;b&amp;gt;Date: &amp;lt;/b&amp;gt;&lt;b&gt;${date.date}&lt;/b&gt;&amp;lt;/c:if&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;p&gt;To deploy the &lt;tt&gt;date&lt;/tt&gt; application with NetBeans IDE, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Start the Application Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In NetBeans IDE, select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;date&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;date&lt;/tt&gt; project, and select Deploy Project.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy the &lt;tt&gt;date&lt;/tt&gt; application with the Ant tool, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/date/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This command will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/date/build/&lt;/tt&gt; directory, and create a WAR file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Application Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To run the example, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Set the character encoding in your browser to UTF-8.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your browser to &lt;tt&gt;http://localhost:8080/date&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will see a combo box whose entries are locales. Select a
locale and click Get Date. You will see the date expressed in a manner
appropriate for that locale.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Some of the characters might not display properly if you don’t have the
appropriate language files installed on your machine. Consult the user guide or online
help for your operating system to determine how you can install these language
files.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="46178730218" hide="0">
			<date>January  20, 2008</date>
			<title>The Example JSP Pages</title>
			<description>&lt;p&gt;To illustrate JSP technology, this chapter rewrites each servlet in the Duke’s Bookstore
application introduced in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaff.html"&gt;The Example Servlets&lt;/a&gt; as a JSP page (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahb.html#bnahc"&gt;Table 5-1&lt;/a&gt;).&lt;/p&gt;&lt;a name="bnahc"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-1 Duke’s Bookstore Example JSP Pages&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="171*"&gt;&lt;col width="179*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Function&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;JSP Pages&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Enter the
bookstore.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookstore.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Create the bookstore banner.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;banner.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Browse the books offered for sale.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookcatalog.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Add a book to
the shopping cart.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookcatalog.jsp&lt;/tt&gt; and &lt;tt&gt;bookdetails.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Get detailed information on a specific book.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookdetails.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Display the
shopping cart.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookshowcart.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Remove one or more books from the shopping cart.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookshowcart.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Buy the books
in the shopping cart.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookcashier.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Receive an acknowledgment for the purchase.&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;bookreceipt.jsp&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The data for the bookstore application is still maintained in a database and
is accessed through &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/database/BookDBAO.java&lt;/tt&gt;. However, the JSP pages access &lt;tt&gt;BookDBAO&lt;/tt&gt; through the JavaBeans
component &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/database/BookDB.java&lt;/tt&gt;. This class allows the JSP pages to use JSP elements
designed to work with JavaBeans components (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html#bnais"&gt;JavaBeans Component Design Conventions&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;The implementation of the database bean follows. The bean has two instance variables:
the current book and the data access object.&lt;/p&gt;&lt;pre&gt;package database;
public class BookDB {
    private String bookId = "0";
    private BookDBAO database = null;

    public BookDB () throws Exception {
    }
    public void setBookId(String bookId) {
        this.bookId = bookId;
    }
    public void setDatabase(BookDAO database) {
        this.database = database;
    }
    public Book getBook()
         throws Exception {
        return (Book)database.getBook(bookId);
    }
    ...
}&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-314"&gt;&lt;/a&gt;&lt;a name="indexterm-315"&gt;&lt;/a&gt;This version of the Duke’s Bookstore application is organized along the Model-View-Controller (MVC)
architecture. The MVC architecture is a widely used architectural approach for interactive applications
that distributes functionality among application objects so as to minimize the degree of
coupling between the objects. To achieve this, it divides applications into three layers: model,
view, and controller. Each layer handles specific tasks and has responsibilities to the
other layers:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;The &lt;b&gt;model&lt;/b&gt; represents business data, along with
business logic or operations that govern access and modification of
this business data. The model notifies views when it changes and lets
the view query the model about its state. It also lets the controller
access application functionality encapsulated by the model. In the
Duke’s Bookstore application, the shopping cart and database access
object contain the business logic for the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;b&gt;view&lt;/b&gt; renders the contents of a model. It gets data
from the model and specifies how that data should be presented. It
updates data presentation when the model changes. A view also forwards
user input to a controller. The Duke’s Bookstore JSP pages format the
data stored in the session-scoped shopping cart and the page-scoped
database bean.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;b&gt;controller&lt;/b&gt; defines application behavior. It
dispatches user requests and selects views for presentation. It
interprets user inputs and maps them into actions to be performed by
the model. In a web application, user inputs are HTTP &lt;tt&gt;GET&lt;/tt&gt; and &lt;tt&gt;POST&lt;/tt&gt;
requests. A controller selects the next view to display based on the
user interactions and the outcome of the model operations. In the
Duke’s Bookstore application, the &lt;tt&gt;Dispatcher&lt;/tt&gt; servlet is the
controller. It examines the request URL, creates and initializes a
session-scoped JavaBeans component (the shopping cart), and dispatches
requests to view JSP pages.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;hr&gt;&lt;p&gt;&lt;b&gt;Note - &lt;/b&gt;When employed in a web application, the MVC architecture is often referred to
as a Model-2 architecture. The bookstore example discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt;, which intermixes presentation
and business logic, follows what is known as a Model-1 architecture. The Model-2
architecture is the recommended approach to designing web applications.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a name="indexterm-316"&gt;&lt;/a&gt;In addition, this version of the application uses several custom tags from the
JavaServer Pages Standard Tag Library (JSTL), described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnakc.html"&gt;Chapter 7, JavaServer Pages Standard Tag Library&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;c:if&lt;/tt&gt;, &lt;tt&gt;c:choose&lt;/tt&gt;, &lt;tt&gt;c:when&lt;/tt&gt;, and &lt;tt&gt;c:otherwise&lt;/tt&gt; for flow control&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;c:set&lt;/tt&gt; for setting scoped variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;c:url&lt;/tt&gt; for encoding URLs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;fmt:message&lt;/tt&gt;, &lt;tt&gt;fmt:formatNumber&lt;/tt&gt;, and &lt;tt&gt;fmt:formatDate&lt;/tt&gt; for providing locale-sensitive messages, numbers, and dates&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Custom tags are the preferred mechanism for performing a wide variety of dynamic
processing tasks, including accessing databases, using enterprise services such as email and directories,
and implementing flow control. In earlier versions of JSP technology, such tasks were
performed with JavaBeans components in conjunction with scripting elements (discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaon.html"&gt;Chapter 9, Scripting in JSP Pages&lt;/a&gt;). Although still
available in JSP 2.0 technology, scripting elements tend to make JSP pages more
difficult to maintain because they mix presentation and logic, something that is discouraged
in page design. Custom tags are introduced in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaiy.html"&gt;Using Custom Tags&lt;/a&gt; and described in
detail in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Finally, this version of the example contains an applet to generate a dynamic
digital clock in the banner. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaje.html"&gt;Including an Applet&lt;/a&gt; for a description of the
JSP element that generates HTML for downloading the applet.&lt;/p&gt;&lt;p&gt;To deploy and run the application using NetBeans IDE, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Perform all the operations described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaez.html"&gt;Accessing Databases from Web Applications&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In NetBeans IDE, select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;bookstore2&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box and the Open Required Projects check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;bookstore2&lt;/tt&gt; project, and select Deploy Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the application, open the bookstore URL &lt;tt&gt;http://localhost:8080/bookstore2/books/bookstore&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy and run the application using Ant, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This command will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/build/&lt;/tt&gt; directory, and create a WAR file and copy it to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/dist/&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Application Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perform all the operations described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaez.html#bnafb"&gt;Creating a Data Source in the Application Server&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To deploy the example, type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;. The deploy target outputs a URL for running the application. Ignore this URL, and instead use the one shown in the next step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the application, open the bookstore URL &lt;tt&gt;http://localhost:8080/bookstore2/books/bookstore&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To learn how to configure the example, refer to the deployment descriptor (the
&lt;tt&gt;web.xml&lt;/tt&gt; file), which includes the following configurations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A &lt;tt&gt;display-name&lt;/tt&gt; element that specifies the name that tools use to identify the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;context-param&lt;/tt&gt; element that specifies the JSTL resource bundle base name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;listener&lt;/tt&gt; element that identifies the &lt;tt&gt;ContextListener&lt;/tt&gt; class used to create and remove the database access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;servlet&lt;/tt&gt; element that identifies the &lt;tt&gt;Dispatcher&lt;/tt&gt; servlet instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A set of &lt;tt&gt;servlet-mapping&lt;/tt&gt; elements that map &lt;tt&gt;Dispatcher&lt;/tt&gt; to URL patterns for each of the JSP pages in the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nested inside a &lt;tt&gt;jsp-config&lt;/tt&gt; element are two &lt;tt&gt;jsp-property-group&lt;/tt&gt; elements, which define the preludes and coda to be included in each page. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html"&gt;Setting Properties for Groups of JSP Pages&lt;/a&gt; for more information.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahb.html#bnahd"&gt;Figure 5-2&lt;/a&gt; shows the &lt;tt&gt;bookcatalog.jsp&lt;/tt&gt; page from the Duke’s Bookstore application. This page
displays a list of all the books that are available for purchase.&lt;/p&gt;&lt;a name="bnahd"&gt;&lt;/a&gt;&lt;h6&gt;Figure 5-2 Book Catalog&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-bookCatalog1.gif" alt="Screen capture of Duke&amp;#8216;s Bookstore book catalog, with titles, authors, prices, and " add="" cart="" links.="" titles="" are="" links="" to="" book="" details.="" height="867" width="662"&gt;&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaff.html#bnafh"&gt;Troubleshooting Duke&amp;#8216;s Bookstore Database Problems&lt;/a&gt; for help with diagnosing common problems related to the database server.
If the messages in your pages appear as strings of the form
&lt;tt&gt;???&lt;/tt&gt; &lt;tt&gt;Key&lt;/tt&gt; &lt;tt&gt;???&lt;/tt&gt;, the likely cause is that you have not provided the
correct resource bundle base name as a context parameter.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="45835389705" hide="0">
			<date>January  20, 2008</date>
			<title>The Life Cycle of a JSP Page</title>
			<description>&lt;p&gt;A JSP page services requests as a servlet. Thus, the life cycle and
many of the capabilities of JSP pages (in particular the dynamic aspects) are
determined by Java Servlet technology. You will notice that many sections in this
chapter refer to classes and methods described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-318"&gt;&lt;/a&gt;&lt;a name="indexterm-319"&gt;&lt;/a&gt;When a request is mapped to a JSP page, the web container first
checks whether the JSP page’s servlet is older than the JSP page. If
the servlet is older, the web container translates the JSP page into a
servlet class and compiles the class. During development, one of the advantages of
JSP pages over servlets is that the build process is performed automatically.&lt;/p&gt;

&lt;a name="bnahf"&gt;&lt;/a&gt;&lt;h4&gt;Translation and Compilation&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-320"&gt;&lt;/a&gt;During the translation phase each type of data in a JSP page is
treated differently. Static data is transformed into code that will emit the data
into the response stream. JSP elements are treated as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-321"&gt;&lt;/a&gt;Directives are used to control how the web container translates and executes the JSP page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scripting elements are inserted into the JSP page’s servlet class. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaon.html"&gt;Chapter 9, Scripting in JSP Pages&lt;/a&gt; for details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expression language expressions are passed as parameters to calls to the JSP expression evaluator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;jsp:[set|get]Property&lt;/tt&gt; elements are converted into method calls to JavaBeans components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;jsp:[include|forward]&lt;/tt&gt;elements are converted into invocations of the Java Servlet API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;tt&gt;jsp:plugin&lt;/tt&gt; element is converted into browser-specific markup for activating an applet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom tags are converted into calls to the tag handler that implements the custom tag.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In the Application Server, the source for the servlet created from a JSP
page named &lt;i&gt;pageName&lt;/i&gt; is in this file:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;domain-dir&lt;/i&gt;/generated/jsp/j2ee-modules/&lt;i&gt;WAR-NAME&lt;/i&gt;/&lt;i&gt;pageName&lt;/i&gt;_jsp.java&lt;/pre&gt;&lt;p&gt;For example, the source for the index page (named &lt;tt&gt;index.jsp&lt;/tt&gt;) for the &lt;tt&gt;date&lt;/tt&gt;
localization example discussed at the beginning of the chapter would be named:&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;/tt&gt;&lt;i&gt;domain-dir&lt;/i&gt;&lt;tt&gt;/generated/jsp/j2ee-modules/date/index_jsp.java&lt;/tt&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-322"&gt;&lt;/a&gt;&lt;a name="indexterm-323"&gt;&lt;/a&gt;Both the translation and the compilation phases can yield errors that are observed
only when the page is requested for the first time. If an error
is encountered during either phase, the server will return &lt;tt&gt;JasperException&lt;/tt&gt; and a message
that includes the name of the JSP page and the line where the
error occurred.&lt;/p&gt;&lt;p&gt;After the page has been translated and compiled, the JSP page’s servlet (for
the most part) follows the servlet life cycle described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafi.html"&gt;Servlet Life Cycle&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;If an instance of the JSP page’s servlet does not exist, the container:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Loads the JSP page’s servlet class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instantiates an instance of the servlet class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initializes the servlet instance by calling the &lt;tt&gt;jspInit&lt;/tt&gt; method&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The container invokes the &lt;tt&gt;_jspService&lt;/tt&gt; method, passing request and response objects.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;If the container needs to remove the JSP page’s servlet, it calls the
&lt;tt&gt;jspDestroy&lt;/tt&gt; method.&lt;/p&gt;

&lt;a name="bnahg"&gt;&lt;/a&gt;&lt;h4&gt;Execution&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-324"&gt;&lt;/a&gt;&lt;a name="indexterm-325"&gt;&lt;/a&gt;You can control various JSP page execution parameters by using &lt;tt&gt;page&lt;/tt&gt; directives. The
directives that pertain to buffering output and handling errors are discussed here. Other
directives are covered in the context of specific page-authoring tasks throughout the chapter.&lt;/p&gt;

&lt;a name="bnahh"&gt;&lt;/a&gt;&lt;h5&gt;Buffering&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-326"&gt;&lt;/a&gt;When a JSP page is executed, output written to the response object is
automatically buffered. You can set the size of the buffer using the
following page directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page buffer="none|&lt;i&gt;xxx&lt;/i&gt;kb" %&amp;gt;&lt;/pre&gt;&lt;p&gt;A larger buffer allows more content to be written before anything is actually
sent back to the client, thus providing the JSP page with more
time to set appropriate status codes and headers or to forward to another
web resource. A smaller buffer decreases server memory load and allows the client
to start receiving data more quickly.&lt;/p&gt;

&lt;a name="bnahi"&gt;&lt;/a&gt;&lt;h5&gt;Handling JSP Page Errors&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-327"&gt;&lt;/a&gt;Any number of exceptions can arise when a JSP page is executed. To
specify that the web container should forward control to an error page if
an exception occurs, include the following &lt;tt&gt;page&lt;/tt&gt; directive at the beginning of
your JSP page:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page errorPage="&lt;i&gt;file-name&lt;/i&gt;" %&amp;gt;&lt;/pre&gt;&lt;p&gt;The Duke’s Bookstore application page &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/web/template/preludeErrorPage.jspf&lt;/tt&gt; contains the directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page errorPage="errorpage.jsp"%&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-328"&gt;&lt;/a&gt;The following page directive at the beginning of &lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/web/error/errorpage.jsp&lt;/tt&gt; indicates that it is
serving as an error page:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page isErrorPage="true" %&amp;gt;&lt;/pre&gt;&lt;p&gt;This directive makes an object of type &lt;a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/jsp/ErrorData.html"&gt;javax.servlet.jsp.ErrorData&lt;/a&gt; available to the error
page so that you can retrieve, interpret, and possibly display information about the cause
of the exception in the error page. You access the error data
object in an EL (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html"&gt;Unified Expression Language&lt;/a&gt;) expression by way of the page context. Thus,
&lt;tt&gt;${pageContext.errorData.statusCode}&lt;/tt&gt; retrieves the status code, and &lt;tt&gt;${pageContext.errorData.throwable}&lt;/tt&gt; retrieves the exception. You can
retrieve the cause of the exception using this expression:&lt;/p&gt;&lt;pre&gt;${pageContext.errorData.throwable.cause}&lt;/pre&gt;&lt;p&gt;For example, the error page for Duke’s Bookstore is as follows:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page isErrorPage="true" %&amp;gt;
&amp;lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core"
     prefix="c" %&amp;gt;
&amp;lt;%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
     prefix="fmt" %&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;&amp;lt;fmt:message key="ServerError"/&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body bgcolor="white"&amp;gt;
&amp;lt;h3&amp;gt;
&amp;lt;fmt:message key="ServerError"/&amp;gt;
&amp;lt;/h3&amp;gt;
&amp;lt;p&amp;gt;
: ${pageContext.errorData.throwable.cause}
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;hr&gt;&lt;p&gt;&lt;b&gt;Note - &lt;/b&gt;&lt;a name="indexterm-329"&gt;&lt;/a&gt;&lt;a name="indexterm-330"&gt;&lt;/a&gt;You can also define error pages for the WAR that contains a
JSP page. If error pages are defined for both the WAR and a
JSP page, the JSP page’s error page takes precedence.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="4363602955" hide="0">
			<date>January  20, 2008</date>
			<title>Creating Static Content</title>
			<description>&lt;p&gt;You create static content in a JSP page simply by writing it
as if you were creating a page that consisted only of that content.
Static content can be expressed in any text-based format, such as HTML, Wireless
Markup Language (WML), and XML. The default format is HTML. If you want
to use a format other than HTML, at the beginning of your JSP
page you include a &lt;tt&gt;page&lt;/tt&gt; directive with the &lt;tt&gt;contentType&lt;/tt&gt; attribute set to the
content type. The purpose of the &lt;tt&gt;contentType&lt;/tt&gt; directive is to allow the browser to
correctly interpret the resulting content. So if you wanted a page to contain
data expressed in WML, you would include the following directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page contentType="text/vnd.wap.wml"%&amp;gt;&lt;/pre&gt;&lt;p&gt;A registry of content type names is kept by the IANA at
&lt;a href="http://www.iana.org/assignments/media-types/"&gt;http://www.iana.org/assignments/media-types/&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnahk"&gt;&lt;/a&gt;&lt;h4&gt;Response and Page Encoding&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-332"&gt;&lt;/a&gt;You also use the &lt;tt&gt;contentType&lt;/tt&gt; attribute to specify the encoding of the response.
For example, the date application specifies that the page should be encoded using
UTF-8, an encoding that supports almost all locales, using the following &lt;tt&gt;page&lt;/tt&gt; directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page contentType="text/html; charset=UTF-8" %&amp;gt;&lt;/pre&gt;&lt;p&gt;If the response encoding weren’t set, the localized dates would not be rendered
correctly.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-333"&gt;&lt;/a&gt;To set the source encoding of the page itself, you would use
the following &lt;tt&gt;page&lt;/tt&gt; directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page pageEncoding="UTF-8" %&amp;gt;&lt;/pre&gt;&lt;p&gt;You can also set the page encoding of a set of JSP
pages. The value of the page encoding varies depending on the configuration specified
in the JSP configuration section of the web application deployment descriptor (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html#bnajk"&gt;Declaring Page Encodings&lt;/a&gt;).&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="22726536186" hide="0">
			<date>January  20, 2008</date>
			<title>Creating Dynamic Content</title>
			<description>&lt;p&gt;You create dynamic content by accessing Java programming language object properties.&lt;/p&gt;

&lt;a name="bnahm"&gt;&lt;/a&gt;&lt;h4&gt;Using Objects within JSP Pages&lt;/h4&gt;
&lt;p&gt;You can access a variety of objects, including enterprise beans and JavaBeans components,
within a JSP page. JSP technology automatically makes some objects available, and you
can also create and access application-specific objects.&lt;/p&gt;

&lt;a name="bnahn"&gt;&lt;/a&gt;&lt;h5&gt;Using Implicit Objects&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-335"&gt;&lt;/a&gt;&lt;b&gt;Implicit objects&lt;/b&gt; are created by the web container and contain information related to a
particular request, page, session, or application. Many of the objects are defined by
the Java servlet technology underlying JSP technology and are discussed at length in
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafd.html"&gt;Chapter 4, Java Servlet Technology&lt;/a&gt;. The section &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaij"&gt;Implicit Objects&lt;/a&gt; explains how you access implicit objects using the JSP
expression language.&lt;/p&gt;

&lt;a name="bnaho"&gt;&lt;/a&gt;&lt;h5&gt;Using Application-Specific Objects&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-336"&gt;&lt;/a&gt;When possible, application behavior should be encapsulated in objects so that page designers
can focus on presentation issues. Objects can be created by developers who are
proficient in the Java programming language and in accessing databases and other services.
The main way to create and use application-specific objects within a JSP page
is to use JSP standard tags (discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html"&gt;JavaBeans Components&lt;/a&gt;) to create JavaBeans components
and set their properties, and EL expressions to access their properties. You can
also access JavaBeans components and other objects in scripting elements, which are described
in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaon.html"&gt;Chapter 9, Scripting in JSP Pages&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnahp"&gt;&lt;/a&gt;&lt;h5&gt;Using Shared Objects&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-337"&gt;&lt;/a&gt;The conditions affecting concurrent access to shared objects (described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafs"&gt;Controlling Concurrent Access to Shared Resources&lt;/a&gt;) apply to objects
accessed from JSP pages that run as multithreaded servlets. You can use the
following &lt;tt&gt;page&lt;/tt&gt; directive to indicate how a web container should dispatch multiple client
requests:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page isThreadSafe="true|false" %&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-338"&gt;&lt;/a&gt;When the &lt;tt&gt;isThreadSafe&lt;/tt&gt; attribute is set to &lt;tt&gt;true&lt;/tt&gt;, the web container can
choose to dispatch multiple concurrent client requests to the JSP page. This is
the &lt;b&gt;default&lt;/b&gt; setting. If using &lt;tt&gt;true&lt;/tt&gt;, you must ensure that you properly synchronize access
to any shared objects defined at the page level. This includes objects created
within declarations, JavaBeans components with page scope, and attributes of the page context
object (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaij"&gt;Implicit Objects&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;If &lt;tt&gt;isThreadSafe&lt;/tt&gt; is set to &lt;tt&gt;false&lt;/tt&gt;, requests are dispatched one at a time
in the order they were received, and access to page-level objects does not
have to be controlled. However, you still must ensure that access is properly
synchronized to attributes of the &lt;tt&gt;application&lt;/tt&gt; or &lt;tt&gt;session&lt;/tt&gt; scope objects and to
JavaBeans components with application or session scope. Furthermore, it is not recommended to set
&lt;tt&gt;isThreadSafe&lt;/tt&gt; to &lt;tt&gt;false&lt;/tt&gt;. The JSP page’s generated servlet will implement the &lt;tt&gt;javax.servlet.SingleThreadModel&lt;/tt&gt; interface,
and because the Servlet 2.4 specification deprecates &lt;tt&gt;SingleThreadModel&lt;/tt&gt;, the generated servlet will
contain deprecated code.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="3357474161" hide="0">
			<date>January  20, 2008</date>
			<title>Unified Expression Language</title>
			<description>&lt;p&gt;The primary new feature of JSP 2.1 is the unified expression language (unified EL),
which represents a union of the expression language offered by JSP 2.0 and
the expression language created for JavaServer Faces technology (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaph.html"&gt;Chapter 10, JavaServer Faces Technology&lt;/a&gt;) version 1.0.&lt;/p&gt;&lt;p&gt;The expression language introduced in JSP 2.0 allows page authors to use simple
expressions to dynamically read data from JavaBeans components. For example, the &lt;tt&gt;test&lt;/tt&gt; attribute
of the following conditional tag is supplied with an EL expression that compares
the number of items in the session-scoped bean named &lt;tt&gt;cart&lt;/tt&gt; with 0.&lt;/p&gt;&lt;pre&gt;&amp;lt;c:if test="${sessionScope.cart.numberOfItems &amp;gt; 0}"&amp;gt;
  ...
&amp;lt;/c:if&amp;gt;&lt;/pre&gt;&lt;p&gt;As explained in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahe.html"&gt;The Life Cycle of a JSP Page&lt;/a&gt;, JSP supports a simple request/response life cycle, during which
a page is executed and the HTML markup is rendered immediately. Therefore, the
simple, read-only expression language offered by JSP 2.0 was well suited to the
needs of JSP applications.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-340"&gt;&lt;/a&gt;JavaServer Faces technology, on the other hand, features a multiphase life cycle designed to
support its sophisticated UI component model, which allows for converting and validating component
data, propagating component data to objects, and handling component events. To facilitate these
functions, JavaServer Faces technology introduced its own expression language that included the following functionality:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Deferred evaluation of expressions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to set data as well as get data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to invoke methods&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaqm.html#bnaqp"&gt;Using the Unified EL to Reference Backing Beans&lt;/a&gt; for more information on how to use the unified EL
in JavaServer Faces applications.&lt;/p&gt;&lt;p&gt;These two expression languages have been unified for a couple reasons. One reason
is so that page authors can mix JSP content with JavaServer Faces tags
without worrying about conflicts caused by the different life cycles these technologies support.
Another reason is so that other JSP-based technologies could make use of the
additional features similarly to the way JavaServer Faces technology uses them. In fact,
although the standard JSP tags and static content continue to use only those
features present in JSP 2.0, authors of JSP custom tags can create tags
that take advantage of the new set of features in the unified expression
language.&lt;/p&gt;&lt;p&gt;To summarize, the new, unified expression language allows page authors to use simple
expressions to perform the following tasks:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Dynamically read application data stored in JavaBeans components, various data structures, and implicit objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamically write data, such as user input into forms, to JavaBeans components&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Invoke arbitrary static and public methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamically perform arithmetic operations&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The unified EL also allows custom tag developers to specify which of the
following kinds of expressions that a custom tag attribute will accept:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-341"&gt;&lt;/a&gt;&lt;a name="indexterm-342"&gt;&lt;/a&gt;&lt;b&gt;Immediate evaluation expressions&lt;/b&gt; or &lt;b&gt;deferred evaluation expressions&lt;/b&gt;.
An immediate evaluation expression is evaluated immediately by the JSP
engine. A deferred evaluation expression can be evaluated later by the
underlying technology using the expression language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-343"&gt;&lt;/a&gt;&lt;a name="indexterm-344"&gt;&lt;/a&gt;&lt;b&gt;Value expression&lt;/b&gt; or &lt;b&gt;method expression&lt;/b&gt;. A value expression references data, whereas a method expression invokes a method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a name="indexterm-345"&gt;&lt;/a&gt;&lt;a name="indexterm-346"&gt;&lt;/a&gt;&lt;b&gt;Rvalue expression&lt;/b&gt; or &lt;b&gt;Lvalue expression&lt;/b&gt;.
An rvalue expression can only read a value, whereas an lvalue
expression can both read and write that value to an external object.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Finally, the unified EL also provides a pluggable API for resolving expressions so
that application developers can implement their own resolvers that can handle expressions not
already supported by the unified EL.&lt;/p&gt;&lt;p&gt;This section gives an overview of the unified expression language features by explaining
the following topics:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnahr"&gt;Immediate and Deferred Evaluation Syntax&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnahu"&gt;Value and Method Expressions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaia"&gt;Defining a Tag Attribute Type&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaic"&gt;Deactivating Expression Evaluation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaid"&gt;Literal Expressions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaif"&gt;Resolving Expressions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaij"&gt;Implicit Objects&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaik"&gt;Operators&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnail"&gt;Reserved Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaim"&gt;Examples of EL Expressions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaio"&gt;Functions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnahr"&gt;&lt;/a&gt;&lt;h4&gt;Immediate and Deferred Evaluation Syntax&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-347"&gt;&lt;/a&gt;&lt;a name="indexterm-348"&gt;&lt;/a&gt;The unified EL supports both immediate and deferred evaluation of expressions. &lt;b&gt;Immediate evaluation&lt;/b&gt; means
that the JSP engine evaluates the expression and returns the result immediately when
the page is first rendered. &lt;b&gt;Deferred evaluation&lt;/b&gt; means that the technology using the expression language
can employ its own machinery to evaluate the expression sometime later during the
page’s life cycle, whenever it is appropriate to do so.&lt;/p&gt;&lt;p&gt;Those expressions that are evaluated immediately use the &lt;tt&gt;${}&lt;/tt&gt; syntax, which was introduced
with the JSP 2.0 expression language. Expressions whose evaluation is deferred use the
&lt;tt&gt;#{}&lt;/tt&gt; syntax, which was introduced by JavaServer Faces technology.&lt;/p&gt;&lt;p&gt;Because of its multiphase life cycle, JavaServer Faces technology uses deferred evaluation expressions.
During the life cycle, component events are handled, data is validated, and other
tasks are performed, all done in a particular order. Therefore, it must defer
evaluation of expressions until the appropriate point in the life cycle.&lt;/p&gt;&lt;p&gt;Other technologies using the unified EL might have different reasons for using deferred
expressions.&lt;/p&gt;

&lt;a name="bnahs"&gt;&lt;/a&gt;&lt;h5&gt;Immediate Evaluation&lt;/h5&gt;
&lt;p&gt;All expressions using the &lt;tt&gt;${}&lt;/tt&gt; syntax are evaluated immediately. These expressions can only
be used within template text or as the value of a JSP tag
attribute that can accept runtime expressions.&lt;/p&gt;&lt;p&gt;The following example shows a tag whose value attribute references an immediate evaluation
expression that gets the total price from the session-scoped bean named cart:&lt;/p&gt;&lt;pre&gt;&amp;lt;fmt:formatNumber value="${sessionScope.cart.total}"/&amp;gt;&lt;/pre&gt;&lt;p&gt;The JSP engine evaluates the expression, &lt;tt&gt;${sessionScope.cart.total}&lt;/tt&gt;, converts it, and passes the
returned value to the tag handler.&lt;/p&gt;&lt;p&gt;Immediate evaluation expressions are always read-only value expressions. The expression shown above can
only get the total price from the cart bean; it cannot set the
total price.&lt;/p&gt;

&lt;a name="bnaht"&gt;&lt;/a&gt;&lt;h5&gt;Deferred Evaluation&lt;/h5&gt;
&lt;p&gt;Deferred evaluation expressions take the form &lt;tt&gt;#{expr}&lt;/tt&gt; and can be evaluated at other
phases of a page life cycle as defined by whatever technology is using
the expression. In the case of JavaServer Faces technology, its controller can evaluate
the expression at different phases of the life cycle depending on how the
expression is being used in the page.&lt;/p&gt;&lt;p&gt;The following example shows a JavaServer Faces &lt;tt&gt;inputText&lt;/tt&gt; tag, which represents a text
field component into which a user enters a value. The &lt;tt&gt;inputText&lt;/tt&gt; tag’s &lt;tt&gt;value&lt;/tt&gt;
attribute references a deferred evaluation expression that points to the &lt;tt&gt;name&lt;/tt&gt; property of the
&lt;tt&gt;customer&lt;/tt&gt; bean.&lt;/p&gt;&lt;pre&gt;&amp;lt;h:inputText id="name" value="#{customer.name}" /&amp;gt;&lt;/pre&gt;&lt;p&gt;For an initial request of the page containing this tag, the JavaServer Faces
implementation evaluates the &lt;tt&gt;#{customer.name}&lt;/tt&gt; expression during the render response phase of the life
cycle. During this phase, the expression merely accesses the value of &lt;tt&gt;name&lt;/tt&gt; from
the &lt;tt&gt;customer&lt;/tt&gt; bean, as is done in immediate evaluation.&lt;/p&gt;&lt;p&gt;For a postback, the JavaServer Faces implementation evaluates the expression at different phases
of the life cycle, during which the value is retrieved from the request,
validated, and propagated to the &lt;tt&gt;customer&lt;/tt&gt; bean.&lt;/p&gt;&lt;p&gt;As shown in this example, deferred evaluation expressions can be value expressions that
can be used to both read and write data. They can also
be method expressions. Value expressions (both immediate and deferred) and method expressions are explained
in the next section.&lt;/p&gt;

&lt;a name="bnahu"&gt;&lt;/a&gt;&lt;h4&gt;Value and Method Expressions&lt;/h4&gt;
&lt;p&gt;The unified EL defines two kinds of expressions: value expressions and method expressions.
Value expressions can either yield a value or set a value. Method expressions
reference methods that can be invoked and can return a value.&lt;/p&gt;

&lt;a name="bnahv"&gt;&lt;/a&gt;&lt;h5&gt;Value Expressions&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-349"&gt;&lt;/a&gt;&lt;a name="indexterm-350"&gt;&lt;/a&gt;&lt;a name="indexterm-351"&gt;&lt;/a&gt;Value expressions can be further categorized into rvalue and lvalue expressions. &lt;b&gt;Rvalue expressions&lt;/b&gt; are
those that can read data, but cannot write it. &lt;b&gt;Lvalue expressions&lt;/b&gt; can both read and
write data.&lt;/p&gt;&lt;p&gt;All expressions that are evaluated immediately use the &lt;tt&gt;${}&lt;/tt&gt; delimiters and are always
rvalue expressions. Expressions whose evaluation can be deferred use the &lt;tt&gt;#{}&lt;/tt&gt; delimiters and
can act as both rvalue and lvalue expressions. Consider these two value expressions:&lt;/p&gt;&lt;pre&gt;&amp;lt;taglib:tag value="${customer.name}" /&amp;gt;
&amp;lt;taglib:tag value="#{customer.name}" /&amp;gt;&lt;/pre&gt;&lt;p&gt;The former uses immediate evaluation syntax, whereas the latter uses deferred evaluation syntax.
The first expression accesses the &lt;tt&gt;name&lt;/tt&gt; property, gets its value, and the value
is added to the response and rendered on the page. The same thing
can happen with the second expression. However, the tag handler can defer the
evaluation of this expression to a later time in the page life cycle,
if the technology using this tag allows it.&lt;/p&gt;&lt;p&gt;In the case of JavaServer Faces technology, the latter tag’s expression is evaluated
immediately during an initial request for the page. In this case, this expression
acts as an rvalue expression. During a postback, this expression can be used
to set the value of the &lt;tt&gt;name&lt;/tt&gt; property with user input. In this
situation, the expression acts as an lvalue expression.&lt;/p&gt;

&lt;a name="bnahw"&gt;&lt;/a&gt;&lt;h5&gt;Referencing Objects Using Value Expressions&lt;/h5&gt;
&lt;p&gt;Both rvalue and lvalue expressions can refer to the following objects and their
properties or attributes:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;JavaBeans components&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java SE enumerated types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implicit objects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaij"&gt;Implicit Objects&lt;/a&gt; for more detail on the implicit objects available with JSP technology.&lt;/p&gt;&lt;p&gt;To refer to these objects, you write an expression using a variable name
with which you created the object. The following expression references a JavaBeans component
called &lt;tt&gt;customer&lt;/tt&gt;.&lt;/p&gt;&lt;pre&gt;${customer}&lt;/pre&gt;&lt;p&gt;The web container evaluates a variable that appears in an expression by looking
up its value according to the behavior of &lt;tt&gt;PageContext.findAttribute(String)&lt;/tt&gt;, where the &lt;tt&gt;String&lt;/tt&gt;
argument is the name of the variable. For example, when evaluating the expression
&lt;tt&gt;${customer}&lt;/tt&gt;, the container will look for &lt;tt&gt;customer&lt;/tt&gt; in the page, request, session, and application
scopes and will return its value. If &lt;tt&gt;customer&lt;/tt&gt; is not found, null is
returned. A variable that matches one of the implicit objects described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaij"&gt;Implicit Objects&lt;/a&gt;
will return that implicit object instead of the variable’s value.&lt;/p&gt;&lt;p&gt;You can alter the way variables are resolved with a custom EL
resolver, which is a new feature of the unified EL. For instance, you
can provide an EL resolver that intercepts objects with the name &lt;tt&gt;customer&lt;/tt&gt;, so that
&lt;tt&gt;${customer}&lt;/tt&gt; returns a value in the EL resolver instead. However, you cannot override
implicit objects in this way. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaih"&gt;EL Resolvers&lt;/a&gt; for more information on EL
resolvers.&lt;/p&gt;&lt;p&gt;You can set the variable name, &lt;tt&gt;customer&lt;/tt&gt;, when you declare the bean. See
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html#bnait"&gt;Creating and Using a JavaBeans Component&lt;/a&gt; for information on how to declare a JavaBeans component for use in
your JSP pages.&lt;/p&gt;&lt;p&gt;To declare beans in JavaServer Faces applications, you use the managed bean facility.
See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaqm.html"&gt;Backing Beans&lt;/a&gt; for information on how to declare beans for use in JavaServer
Faces applications.&lt;/p&gt;&lt;p&gt;When referencing an enum constant with an expression, you use a &lt;tt&gt;String&lt;/tt&gt;
literal. For example, consider this Enum class:&lt;/p&gt;&lt;pre&gt;public enum Suit {hearts, spades, diamonds, clubs}&lt;/pre&gt;&lt;p&gt;To refer to the &lt;tt&gt;Suit&lt;/tt&gt; constant, &lt;tt&gt;Suit.hearts&lt;/tt&gt; with an expression, you use the
&lt;tt&gt;String&lt;/tt&gt; literal, &lt;tt&gt;"hearts"&lt;/tt&gt;. Depending on the context, the &lt;tt&gt;String&lt;/tt&gt; literal is converted to the
enum constant automatically. For example, in the following expression in which &lt;tt&gt;mySuit&lt;/tt&gt; is
an instance of &lt;tt&gt;Suit&lt;/tt&gt;, &lt;tt&gt;"hearts"&lt;/tt&gt; is first converted to a &lt;tt&gt;Suit.hearts&lt;/tt&gt; before it
is compared to the instance.&lt;/p&gt;&lt;pre&gt;${mySuit == "hearts"}&lt;/pre&gt;

&lt;a name="bnahx"&gt;&lt;/a&gt;&lt;h5&gt;Referring to Object Properties Using Value Expressions&lt;/h5&gt;
&lt;p&gt;To refer to properties of a bean or an Enum instance, items
of a collection, or attributes of an implicit object, you use the &lt;tt&gt;.&lt;/tt&gt;
or &lt;tt&gt;[]&lt;/tt&gt; notation, which is similar to the notation used by ECMAScript.&lt;/p&gt;&lt;p&gt;So, if you wanted to reference the &lt;tt&gt;name&lt;/tt&gt; property of the &lt;tt&gt;customer&lt;/tt&gt; bean,
you could use either the expression &lt;tt&gt;${customer.name}&lt;/tt&gt; or the expression &lt;tt&gt;${customer["name"]}&lt;/tt&gt;. The part
inside the square brackets is a &lt;tt&gt;String&lt;/tt&gt; literal that is the name of
the property to reference.&lt;/p&gt;&lt;p&gt;You can use double or single quotes for the &lt;tt&gt;String&lt;/tt&gt; literal. You can
also combine the &lt;tt&gt;[]&lt;/tt&gt; and &lt;tt&gt;.&lt;/tt&gt; notations, as shown here:&lt;/p&gt;&lt;pre&gt;${customer.address["street"]}&lt;/pre&gt;&lt;p&gt;Properties of an enum can also be referenced in this way. However,
as with JavaBeans component properties, the Enum class’s properties must follow JavaBeans component conventions.
This means that a property must at least have an accessor method called
&lt;tt&gt;get&amp;lt;Property&amp;gt;&lt;/tt&gt; (where &lt;tt&gt;&amp;lt;Property&amp;gt;&lt;/tt&gt; is the name of the property) so that an
expression can reference it.&lt;/p&gt;&lt;p&gt;For example, say you have an Enum class that encapsulates the names of
the planets of our galaxy and includes a method to get the
mass of a planet. You can use the following expression to reference the
method &lt;tt&gt;getMass&lt;/tt&gt; of the &lt;tt&gt;Planet&lt;/tt&gt; Enum class:&lt;/p&gt;&lt;pre&gt;${myPlanet.mass}&lt;/pre&gt;&lt;p&gt;If you are accessing an item in an array or list, you
must use either a literal value that can be coerced to int or
the &lt;tt&gt;[]&lt;/tt&gt; notation with an int and without quotes. The following examples could
all resolve to the same item in a list or array, assuming that
&lt;tt&gt;socks&lt;/tt&gt; can be coerced to &lt;tt&gt;int&lt;/tt&gt;:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;${customer.orders[1]}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;${customer.orders.socks}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In contrast, an item in a &lt;tt&gt;Map&lt;/tt&gt; can be accessed using a string
literal key; no coercion is required:&lt;/p&gt;&lt;pre&gt;${customer.orders["socks"]}&lt;/pre&gt;&lt;p&gt;An rvalue expression also refers directly to values that are not objects, such
as the result of arithmetic operations and literal values, as shown by these
examples:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;${"literal"}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;${customer.age + 20}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;${true}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;${57}&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-352"&gt;&lt;/a&gt;The unified expression language defines the following literals:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Boolean: &lt;tt&gt;true&lt;/tt&gt; and &lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integer: as in Java&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Floating point: as in Java&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String: with single and double quotes; &lt;tt&gt;"&lt;/tt&gt; is escaped as &lt;tt&gt;\"&lt;/tt&gt;, &lt;tt&gt;’&lt;/tt&gt; is escaped as &lt;tt&gt;\&amp;#8216;&lt;/tt&gt;, and &lt;tt&gt;\&lt;/tt&gt; is escaped as &lt;tt&gt;\\&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Null: &lt;tt&gt;null&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;You can also write expressions that perform operations on an enum constant. For
example, consider the following Enum class:&lt;/p&gt;&lt;pre&gt;public enum Suit {club, diamond, heart, spade }&lt;/pre&gt;&lt;p&gt;After declaring an enum constant called &lt;tt&gt;mySuit&lt;/tt&gt;, you can write the following expression
to test if &lt;tt&gt;mySuit&lt;/tt&gt; is &lt;tt&gt;spade&lt;/tt&gt;:&lt;/p&gt;&lt;pre&gt;${mySuit == "spade"}&lt;/pre&gt;&lt;p&gt;When the EL resolving mechanism resolves this expression it will invoke the &lt;tt&gt;valueOf&lt;/tt&gt;
method of the Enum class with the &lt;tt&gt;Suit&lt;/tt&gt; class and the &lt;tt&gt;spade&lt;/tt&gt; type,
as shown here:&lt;/p&gt;&lt;pre&gt;mySuit.valueOf(Suit.class, "spade"}&lt;/pre&gt;&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html"&gt;JavaBeans Components&lt;/a&gt; for more information on using expressions to reference JavaBeans components and
their properties.&lt;/p&gt;

&lt;a name="bnahy"&gt;&lt;/a&gt;&lt;h5&gt;Where Value Expressions Can Be Used&lt;/h5&gt;
&lt;p&gt;Value expressions using the &lt;tt&gt;${}&lt;/tt&gt; delimiters can be used in the following places:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;In static text&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In any standard or custom tag attribute that can accept an expression&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The value of an expression in static text is computed and inserted
into the current output. Here is an example of an expression embedded in
static text:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag&amp;gt;
    some text ${expr} some text
&amp;lt;/some:tag&amp;gt;&lt;/pre&gt;&lt;p&gt;If the static text appears in a tag body, note that an
expression &lt;b&gt;will not&lt;/b&gt; be evaluated if the body is declared to be &lt;tt&gt;tagdependent&lt;/tt&gt;
(see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaln.html#bnalo"&gt;Tags with Attributes&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;Lvalue expressions can only be used in tag attributes that can accept lvalue
expressions.&lt;/p&gt;&lt;p&gt;There are three ways to set a tag attribute value using either
an rvalue or lvalue expression:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;With a single expression construct:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag value="${expr}"/&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;another:tag value="#{expr}"/&amp;gt;&lt;/pre&gt;&lt;p&gt;These expressions are evaluated and the result is coerced to the attribute’s expected type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With one or more expressions separated or surrounded by text:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag value="some${expr}${expr}text${expr}"/&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;another:tag value="some#{expr}#{expr}text#{expr}"/&amp;gt;&lt;/pre&gt;&lt;p&gt;These kinds of expression are called a &lt;b&gt;composite expressions&lt;/b&gt;. They are evaluated from left to right. Each expression embedded in the composite expression is coerced to a &lt;tt&gt;String&lt;/tt&gt; and then concatenated with any intervening text. The resulting &lt;tt&gt;String&lt;/tt&gt; is then coerced to the attribute’s expected type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With text only:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag value="sometext"/&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-353"&gt;&lt;/a&gt;This expression is called a &lt;b&gt;literal expression&lt;/b&gt;. In this case, the attribute’s &lt;tt&gt;String&lt;/tt&gt; value is coerced to the attribute’s expected type. Literal value expressions have special syntax rules. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaid"&gt;Literal Expressions&lt;/a&gt;
for more information. When a tag attribute has an enum type, the
expression that the attribute uses must be a literal expression. For
example, the tag attribute can use the expression &lt;tt&gt;"hearts"&lt;/tt&gt; to mean &lt;tt&gt;Suit.hearts&lt;/tt&gt;. The literal is coerced to &lt;tt&gt;Suit&lt;/tt&gt; and the attribute gets the value &lt;tt&gt;Suit.hearts&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-354"&gt;&lt;/a&gt;All expressions used to set attribute values are evaluated in the context of
an expected type. If the result of the expression evaluation does not match
the expected type exactly, a type conversion will be performed. For example, the
expression &lt;tt&gt;${1.2E4}&lt;/tt&gt; provided as the value of an attribute of type &lt;tt&gt;float&lt;/tt&gt;
will result in the following conversion:&lt;/p&gt;&lt;pre&gt;Float.valueOf("1.2E4").floatValue()&lt;/pre&gt;&lt;p&gt;See section 1.18 of the &lt;i&gt;JavaServer Pages 2.1 Expression Language Specification&lt;/i&gt; (available from &lt;a href="http://jcp.org/aboutJava/communityprocess/final/jsr245/"&gt;http://jcp.org/aboutJava/communityprocess/final/jsr245/&lt;/a&gt;) for the complete type
conversion rules.&lt;/p&gt;

&lt;a name="bnahz"&gt;&lt;/a&gt;&lt;h5&gt;Method Expressions&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-355"&gt;&lt;/a&gt;Another feature of the unified expression language is its support of deferred method
expressions. A method expression is used to invoke an arbitrary public method, which
can return a result. A similar feature of the unified EL is functions.
Method expressions differ from functions in many ways. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaio"&gt;Functions&lt;/a&gt; explains more about the differences
between functions and method expressions.&lt;/p&gt;&lt;p&gt;Method expressions primarily benefit JavaServer Faces technology, but they are available to any
technology that can support the unified expression language. Let’s take a look at
how JavaServer Faces technology employs method expressions.&lt;/p&gt;&lt;p&gt;In JavaServer Faces technology, a component tag represents a UI component on a
page. The component tag uses method expressions to invoke methods that perform some
processing for the component. These methods are necessary for handling events that the
components generate and validating component data, as shown in this example:&lt;/p&gt;&lt;pre&gt;&amp;lt;h:form&amp;gt;
    &amp;lt;h:inputText
         id="name"
        value="#{customer.name}"
        validator="#{customer.validateName}"/&amp;gt;
    &amp;lt;h:commandButton
        id="submit"
        action="#{customer.submit}" /&amp;gt;
&amp;lt;/h:form&amp;gt;&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;inputText&lt;/tt&gt; tag displays a &lt;tt&gt;UIInput&lt;/tt&gt; component as a text field. The &lt;tt&gt;validator&lt;/tt&gt;
attribute of this &lt;tt&gt;inputText&lt;/tt&gt; tag references a method, called &lt;tt&gt;validateName&lt;/tt&gt;, in the bean,
called &lt;tt&gt;customer&lt;/tt&gt;. The TLD (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnamu.html"&gt;Tag Library Descriptors&lt;/a&gt;) that defines the &lt;tt&gt;inputText&lt;/tt&gt; tag specifies
what signature the method referred to by the &lt;tt&gt;validator&lt;/tt&gt; attribute must have.
The same is true of the &lt;tt&gt;customer.submit&lt;/tt&gt; method referenced by the &lt;tt&gt;action&lt;/tt&gt; attribute
of the &lt;tt&gt;commandButton&lt;/tt&gt; tag. The TLD specifies that the &lt;tt&gt;submit&lt;/tt&gt; method must return
an &lt;tt&gt;Object&lt;/tt&gt; instance that specifies which page to navigate to next after the
button represented by the &lt;tt&gt;commandButton&lt;/tt&gt; tag is clicked.&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;validation&lt;/tt&gt; method is invoked during the process validation phase of the life
cycle, whereas the &lt;tt&gt;submit&lt;/tt&gt; method is invoked during the invoke application phase of
the life cycle. Because a method can be invoked during different phases of
the life cycle, method expressions must always use the deferred evaluation syntax.&lt;/p&gt;&lt;p&gt;Similarly to lvalue expressions, method expressions can use the . and &lt;tt&gt;[]&lt;/tt&gt;
operators. For example, &lt;tt&gt;#{object.method}&lt;/tt&gt; is equivalent to &lt;tt&gt;#{object["method"]}&lt;/tt&gt;. The literal inside the &lt;tt&gt;[]&lt;/tt&gt;
is coerced to &lt;tt&gt;String&lt;/tt&gt; and is used to find the name of the
method that matches it. Once the method is found, it is invoked or
information about the method is returned.&lt;/p&gt;&lt;p&gt;Method expressions can be used only in tag attributes and only in
the following ways:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;With a single expression construct, where &lt;tt&gt;bean&lt;/tt&gt; refers to a JavaBeans component and &lt;tt&gt;method&lt;/tt&gt; refers to a method of the JavaBeans component:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag value="#{bean.method}"/&amp;gt;&lt;/pre&gt;&lt;p&gt;The
expression is evaluated to a method expression, which is passed to the
tag handler. The method represented by the method expression can then
be invoked later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With text only:&lt;/p&gt;&lt;pre&gt;&amp;lt;some:tag value="sometext"/&amp;gt;&lt;/pre&gt;&lt;p&gt;Method expressions support literals primarily to support &lt;tt&gt;action&lt;/tt&gt; attributes in JavaServer Faces technology. When the method referenced by this method expression is invoked, it returns the &lt;tt&gt;String&lt;/tt&gt; literal, which is then coerced to the expected return type, as defined in the tag’s TLD.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnaia"&gt;&lt;/a&gt;&lt;h4&gt;Defining a Tag Attribute Type&lt;/h4&gt;
&lt;p&gt;As explained in the previous section, all kinds of expressions can be used
in tag attributes. Which kind of expression and how that expression is evaluated
(whether immediately or deferred) is determined by the &lt;tt&gt;type&lt;/tt&gt; attribute of the tag’s
definition in the TLD (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnamu.html"&gt;Tag Library Descriptors&lt;/a&gt;) file that defines the tag.&lt;/p&gt;&lt;p&gt;If you plan to create custom tags (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;), you need to
specify for each tag in the TLD what kind of expression it accepts.
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaib"&gt;Table 5-2&lt;/a&gt; shows the three different kinds of tag attributes that accept EL expressions,
and gives examples of expressions they accept and the type definitions of the attributes
that must be added to the TLD. You cannot use &lt;tt&gt;#{}&lt;/tt&gt; syntax for
a dynamic attribute, meaning an attribute that accepts dynamically-calculated values at runtime. Section
2.3.2 of the JavaServer Pages 2.1 specification refers to these attributes. Neither can
you use the &lt;tt&gt;${}&lt;/tt&gt; syntax for a deferred attribute.&lt;/p&gt;&lt;a name="bnaib"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-2 Definitions of Tag Attributes That Accept EL Expressions&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="72*"&gt;&lt;col width="85*"&gt;&lt;col width="196*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Attribute Type&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Example Expression&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Type Attribute Definition&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;dynamic&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;"literal"&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;rtexprvalue&amp;gt;true&amp;lt;/rtexprvalue&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${literal}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;rtexprvalue&amp;gt;true&amp;lt;/rtexprvalue&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;deferred
value&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;"literal"&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;deferred-value&amp;gt;
   &amp;lt;type&amp;gt;java.lang.String&amp;lt;/type&amp;gt;
&amp;lt;/deferred-value&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;#{customer.age}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;deferred-value&amp;gt;
   &amp;lt;type&amp;gt;int&amp;lt;/type&amp;gt;
&amp;lt;/deferred-value&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td rowspan="2" align="left" valign="top"&gt;&lt;p&gt;deferred method&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;"literal"&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;deferred-method&amp;gt;
   &amp;lt;method-signature&amp;gt;
      java.lang.String submit()
   &amp;lt;/method-signature&amp;gt;
&amp;lt;deferred-method&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;#{customer.calcTotal}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;deferred-method&amp;gt;
   &amp;lt;method-signature&amp;gt;
      double calcTotal(int, double)
   &amp;lt;/method-signature&amp;gt;
&amp;lt;/deferred-method&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;In addition to the tag attribute types shown in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaib"&gt;Table 5-2&lt;/a&gt;, you can
also define an attribute to accept both dynamic and deferred expressions. In this
case, the tag attribute definition contains both an &lt;tt&gt;rtexprvalue&lt;/tt&gt; definition set to &lt;tt&gt;true&lt;/tt&gt;
and either a &lt;tt&gt;deferred-value&lt;/tt&gt; or &lt;tt&gt;deferred-method&lt;/tt&gt; definition.&lt;/p&gt;

&lt;a name="bnaic"&gt;&lt;/a&gt;&lt;h4&gt;Deactivating Expression Evaluation&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-356"&gt;&lt;/a&gt;Because the patterns that identify EL expressions, &lt;tt&gt;${ }&lt;/tt&gt; and &lt;tt&gt;#{ }&lt;/tt&gt;, were not reserved in
the JSP specifications before JSP 2.0, there might exist applications in which such
patterns are intended to pass through verbatim. To prevent the patterns from being
evaluated, you can deactivate EL evaluation using one of the following methods:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Escape the &lt;tt&gt;#{&lt;/tt&gt; or &lt;tt&gt;${&lt;/tt&gt; characters in the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the application with a JSP Property Group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the page with the page directive.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To escape the &lt;tt&gt;#{&lt;/tt&gt; or &lt;tt&gt;${&lt;/tt&gt; characters in the page, you use the
&lt;tt&gt;\&lt;/tt&gt; character as follows:&lt;/p&gt;&lt;pre&gt;some text \#{ some more\${ text
&amp;lt;my:tag someAttribute="sometext\#{more\${text" /&amp;gt;&lt;/pre&gt;&lt;p&gt;Another way to deactivate EL evaluation is by using a JSP property
group to either allow the &lt;tt&gt;#{&lt;/tt&gt; characters as a &lt;tt&gt;String&lt;/tt&gt; literal using the &lt;tt&gt;deferred-syntax-allowed-as-literal&lt;/tt&gt;
subelement, or to treat all expressions as literals using the &lt;tt&gt;el-ignored&lt;/tt&gt; subelement:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp-property-group&amp;gt;
    &amp;lt;deferred-syntax-allowed-as-literal&amp;gt;
        true
    &amp;lt;/deferred-syntax-allowed-as-literal&amp;gt;
&amp;lt;/jsp-property-group&amp;gt;&lt;/pre&gt;&lt;p&gt;or&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp-property-group&amp;gt;
    &amp;lt;el-ignored&amp;gt;true&amp;lt;/el-ignored&amp;gt;
&amp;lt;/jsp-property-group&amp;gt;&lt;/pre&gt;&lt;p&gt;Finally, you can configure the page with the &lt;tt&gt;page&lt;/tt&gt; directive to either accept
the &lt;tt&gt;#{&lt;/tt&gt; characters as &lt;tt&gt;String&lt;/tt&gt; literals with the &lt;tt&gt;deferredSyntaxAllowedAsLiteral&lt;/tt&gt; attribute, or to ignore all
EL expressions using the &lt;tt&gt;isELIgnored&lt;/tt&gt; attribute:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@page ... deferredSyntaxAllowedAsLiteral="true" %&amp;gt;&lt;/pre&gt;&lt;p&gt;or&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ page isELIgnored ="true" %&amp;gt;&lt;/pre&gt;&lt;p&gt;The valid values of these attributes are &lt;tt&gt;true&lt;/tt&gt; and &lt;tt&gt;false&lt;/tt&gt;. If &lt;tt&gt;isELIgnored&lt;/tt&gt;
is &lt;tt&gt;true&lt;/tt&gt;, EL expressions are ignored when they appear in static text or
tag attributes. If it is &lt;tt&gt;false&lt;/tt&gt;, EL expressions are evaluated by the container only
if the attribute has &lt;tt&gt;rtexprvalue&lt;/tt&gt; set to &lt;tt&gt;true&lt;/tt&gt; or the expression is a
deferred expression.&lt;/p&gt;&lt;p&gt;The default value of &lt;tt&gt;isELIgnored&lt;/tt&gt; varies depending on the version of the web
application deployment descriptor. The default mode for JSP pages delivered with a Servlet
2.4 descriptor is to evaluate EL expressions; this automatically provides the default that
most applications want. The default mode for JSP pages delivered using a descriptor
from Servlet 2.3 or before is to ignore EL expressions; this provides backward
compatibility.&lt;/p&gt;

&lt;a name="bnaid"&gt;&lt;/a&gt;&lt;h4&gt;Literal Expressions&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-357"&gt;&lt;/a&gt;A literal expression evaluates to the text of the expression, which is of
type &lt;tt&gt;String&lt;/tt&gt;. It does not use the &lt;tt&gt;${}&lt;/tt&gt; or &lt;tt&gt;#{}&lt;/tt&gt; delimiters.&lt;/p&gt;&lt;p&gt;If you have a literal expression that includes the reserved &lt;tt&gt;${}&lt;/tt&gt; or
&lt;tt&gt;#{}&lt;/tt&gt; syntax, you need to escape these characters as follows.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;By creating a composite expression as shown here:&lt;/p&gt;&lt;pre&gt;${’${’}exprA}&lt;/pre&gt;&lt;pre&gt;#{’#{’}exprB}&lt;/pre&gt;&lt;p&gt;The resulting values would then be the strings &lt;tt&gt;${exprA}&lt;/tt&gt; and &lt;tt&gt;#{exprB}&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The escape characters &lt;tt&gt;\$&lt;/tt&gt; and &lt;tt&gt;\#&lt;/tt&gt; can be used to escape what would otherwise be treated as an eval-expression:&lt;/p&gt;&lt;pre&gt;\${exprA}&lt;/pre&gt;&lt;pre&gt;\#{exprB}&lt;/pre&gt;&lt;p&gt;The resulting values would again be the strings &lt;tt&gt;${exprA}&lt;/tt&gt; and &lt;tt&gt;#{exprB}&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;When a literal expression is evaluated, it can be converted to another type.
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaie"&gt;Table 5-3&lt;/a&gt; shows examples of various literal expressions and their expected types and resulting
values.&lt;/p&gt;&lt;a name="bnaie"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-3 Literal Expressions&lt;/h6&gt;&lt;table ID="Table2"&gt;&lt;col width="75*"&gt;&lt;col width="75*"&gt;&lt;col width="107*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Expression&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Expected Type&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Result&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;Hi&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;String&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;Hi&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;Boolean&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;Boolean.TRUE&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;42&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;int&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;42&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Literal expressions can be evaluated immediately or deferred and can be either value
or method expressions. At what point a literal expression is evaluated depends on
where it is being used. If the tag attribute that uses the literal
expression is defined as accepting a deferred value expression, then the literal expression
references a value and is evaluated at a point in the life cycle
that is determined by where the expression is being used and to what
it is referring.&lt;/p&gt;&lt;p&gt;In the case of a method expression, the method that is referenced
is invoked and returns the specified &lt;tt&gt;String&lt;/tt&gt; literal. The &lt;tt&gt;commandButton&lt;/tt&gt; tag of the
Guess Number application uses a literal method expression as a logical outcome to
tell the JavaServer Faces navigation system which page to display next. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaql.html"&gt;Navigation Model&lt;/a&gt;
for more information on this example.&lt;/p&gt;

&lt;a name="bnaif"&gt;&lt;/a&gt;&lt;h4&gt;Resolving Expressions&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-358"&gt;&lt;/a&gt;The unified EL introduces a new, pluggable API for resolving expressions. The main
pieces of this API are:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;The &lt;tt&gt;ValueExpression&lt;/tt&gt; class, which defines a value expression&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;tt&gt;MethodExpression&lt;/tt&gt; class, which defines a method expression&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An &lt;tt&gt;ELResolver&lt;/tt&gt; class that defines a mechanism for resolving expressions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A set of &lt;tt&gt;ELResolver&lt;/tt&gt; implementations, in which each
implementation is responsible for resolving expressions that reference
a particular type of object or property&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An &lt;tt&gt;ELContext&lt;/tt&gt; object that saves state relating to EL resolution, holds references to EL resolvers, and contains context objects (such as &lt;tt&gt;JspContext&lt;/tt&gt;) needed by the underlying technology to resolve expressions&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Most application developers will not need to use these classes directly unless they
plan to write their own custom EL resolvers. Those writing JavaServer Faces custom
components will definitely need to use &lt;tt&gt;ValueExpression&lt;/tt&gt; and &lt;tt&gt;MethodExpression&lt;/tt&gt;. This section details
how expressions are resolved for the benefit of these developers. It does not
explain how to create a custom resolver. For more information on creating custom
resolvers, see the article &lt;i&gt;The Unified Expression Language&lt;/i&gt;, Ryan Lubke et al., located at &lt;a href="http://java.sun.com/products/jsp/reference/techart/unifiedEL.html"&gt;http://java.sun.com/products/jsp/reference/techart/unifiedEL.html&lt;/a&gt;.
You can also refer to &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bncmt.html#bncmy"&gt;Request Processing&lt;/a&gt;, which explains how the Duke’s Bank
application uses a custom resolver.&lt;/p&gt;

&lt;a name="bnaig"&gt;&lt;/a&gt;&lt;h5&gt;Process of Expression Evaluation&lt;/h5&gt;
&lt;p&gt;When a value expression that is included in a page is parsed
during an initial request for the page, a &lt;tt&gt;ValueExpression&lt;/tt&gt; object is created to represent
the expression. Then, the &lt;tt&gt;ValueExpression&lt;/tt&gt; object’s &lt;tt&gt;getValue&lt;/tt&gt; method is invoked. This method
will in turn invoke the &lt;tt&gt;getValue&lt;/tt&gt; method of the appropriate resolver. A
similar process occurs during a postback when &lt;tt&gt;setValue&lt;/tt&gt; is called if the expression is
an lvalue expression.&lt;/p&gt;&lt;p&gt;In the case of a method expression, a &lt;tt&gt;BeanELResolver&lt;/tt&gt; is used to find
the object that implements the method to be invoked or queried. Similarly to
the process for evaluating value expressions, when a method expression is encountered, a
&lt;tt&gt;MethodExpression&lt;/tt&gt; object is created. Subsequently, either the &lt;tt&gt;invoke&lt;/tt&gt; or &lt;tt&gt;getMethodInfo&lt;/tt&gt; method of the &lt;tt&gt;MethodExpression&lt;/tt&gt;
object is called. This method in turn invokes the &lt;tt&gt;BeanELResolver&lt;/tt&gt; object’s &lt;tt&gt;getValue&lt;/tt&gt; method.
The &lt;tt&gt;getMethodInfo&lt;/tt&gt; is mostly for use by tools.&lt;/p&gt;&lt;p&gt;After a resolver completes resolution of an expression, it sets the &lt;tt&gt;propertyResolved&lt;/tt&gt;
flag of the &lt;tt&gt;ELContext&lt;/tt&gt; to &lt;tt&gt;true&lt;/tt&gt; so that no more resolvers are
consulted.&lt;/p&gt;

&lt;a name="bnaih"&gt;&lt;/a&gt;&lt;h5&gt;EL Resolvers&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-359"&gt;&lt;/a&gt;At the center of the EL machinery is the extensible &lt;tt&gt;ELResolver&lt;/tt&gt; class. A
class that implements &lt;tt&gt;ELResolver&lt;/tt&gt; defines how to resolve expressions referring to a
particular type of object or property. In terms of the following expression, a
&lt;tt&gt;BeanELResolver&lt;/tt&gt; instance is called the first time to find the &lt;b&gt;base&lt;/b&gt; object,
&lt;tt&gt;employee&lt;/tt&gt;, which is a JavaBeans component. Once the resolver finds the object, it
is called again to resolve the &lt;b&gt;property&lt;/b&gt;, &lt;tt&gt;lName&lt;/tt&gt; of the employee object.&lt;/p&gt;&lt;pre&gt;${employee.lName}&lt;/pre&gt;&lt;p&gt;The unified EL includes a set of standard resolver implementations. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaii"&gt;Table 5-4&lt;/a&gt; lists
these standard resolvers and includes example expressions that they can resolve.&lt;/p&gt;&lt;a name="bnaii"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-4 Standard EL Resolvers&lt;/h6&gt;&lt;table ID="Table3"&gt;&lt;col width="103*"&gt;&lt;col width="87*"&gt;&lt;col width="161*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Resolver&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Example Expression&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Description&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ArrayELResolver&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${myArray[1]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Returns the
value at index 1 in the array called &lt;tt&gt;myArray&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;BeanELResolver&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${employee.lName}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Returns the value of
the &lt;tt&gt;lName&lt;/tt&gt; property of the &lt;tt&gt;employee&lt;/tt&gt; bean&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ListELResolver&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${myList[5]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Returns the value at index 5
of &lt;tt&gt;myList&lt;/tt&gt; list&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;MapELResolver&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${myMap.someKey}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Returns the value stored at the key, &lt;tt&gt;someKey&lt;/tt&gt;, in the &lt;tt&gt;Map&lt;/tt&gt;,
&lt;tt&gt;myMap&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ResourceBundleELResolver&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${myRB.myKey}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Returns the message at &lt;tt&gt;myKey&lt;/tt&gt; in the resource bundle called &lt;tt&gt;myRB&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Depending on the technology using the unified EL, other resolvers might be available.
In addition, application developers can add their own implementations of &lt;tt&gt;ELResolver&lt;/tt&gt; to support
resolution of expressions not already supported by the unified EL by registering them
with an application.&lt;/p&gt;&lt;p&gt;All of the standard and custom resolvers available to a particular application are
collected in a chain in a particular order. This chain of resolvers
is represented by a &lt;tt&gt;CompositeELResolver&lt;/tt&gt; instance. When an expression is encountered, the &lt;tt&gt;CompositeELResolver&lt;/tt&gt; instance iterates
over the list of resolvers and consults each resolver until it finds one
that can handle the expression.&lt;/p&gt;&lt;p&gt;If an application is using JSP technology, the chain of resolvers includes the
&lt;tt&gt;ImplicitObjectELResolver&lt;/tt&gt; and the &lt;tt&gt;ScopedAttributeELResolver&lt;/tt&gt;. These are described in the following section.&lt;/p&gt;&lt;p&gt;See section JSP 2.9 of the JavaServer Pages 2.1 specification to find out
the order in which resolvers are chained together in a &lt;tt&gt;CompositeELResolver&lt;/tt&gt; instance.&lt;/p&gt;&lt;p&gt;To learn how to create a custom EL resolver, see &lt;a href="http://java.sun.com/products/jsp/reference/techart/unifiedEL.html"&gt;The Unified Expression Language&lt;/a&gt; .&lt;/p&gt;

&lt;a name="bnaij"&gt;&lt;/a&gt;&lt;h4&gt;Implicit Objects&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-360"&gt;&lt;/a&gt;The JSP expression language defines a set of implicit objects:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;pageContext&lt;/tt&gt;: The context for the JSP page. Provides access to various objects including:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;servletContext&lt;/tt&gt;: The context for the JSP page’s servlet and any web components contained in the same application. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagl.html"&gt;Accessing the Web Context&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;session&lt;/tt&gt;: The session object for the client. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagm.html"&gt;Maintaining Client State&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;request&lt;/tt&gt;: The request triggering the execution of the JSP page. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html#bnafw"&gt;Getting Information from Requests&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;response&lt;/tt&gt;: The response returned by the JSP page. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafv.html#bnafz"&gt;Constructing Responses&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In addition, several implicit objects are available that allow easy access to the following objects:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;param&lt;/tt&gt;: Maps a request parameter name to a single value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;paramValues&lt;/tt&gt;: Maps a request parameter name to an array of values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;header&lt;/tt&gt;: Maps a request header name to a single value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;headerValues&lt;/tt&gt;: Maps a request header name to an array of values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;cookie&lt;/tt&gt;: Maps a cookie name to a single cookie&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;initParam&lt;/tt&gt;: Maps a context initialization parameter name to a single value&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, there are objects that allow access to the various scoped variables described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafp"&gt;Using Scope Objects&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;pageScope&lt;/tt&gt;: Maps page-scoped variable names to their values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;requestScope&lt;/tt&gt;: Maps request-scoped variable names to their values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;sessionScope&lt;/tt&gt;: Maps session-scoped variable names to their values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;applicationScope&lt;/tt&gt;: Maps application-scoped variable names to their values&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;JSP 2.1 provides two EL resolvers to handle expressions that reference these objects:
&lt;tt&gt;ImplicitObjectELResolver&lt;/tt&gt; and &lt;tt&gt;ScopedAttributeELResolver&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;A variable that matches one of the implicit objects is evaluated by
&lt;tt&gt;ImplicitObjectResolver&lt;/tt&gt;, which returns the implicit object. This resolver only handles expressions with a
base of &lt;tt&gt;null&lt;/tt&gt;. What this means for the following expression is that the
&lt;tt&gt;ImplicitObjectResolver&lt;/tt&gt; resolves the &lt;tt&gt;sessionScope&lt;/tt&gt; implicit object only. Once the implicit object is found,
the &lt;tt&gt;MapELResolver&lt;/tt&gt; instance resolves the &lt;tt&gt;profile&lt;/tt&gt; attribute because the &lt;tt&gt;profile&lt;/tt&gt; object represents a map.&lt;/p&gt;&lt;pre&gt;${sessionScope.profile}&lt;/pre&gt;&lt;p&gt;&lt;tt&gt;ScopedAttributeELResolver&lt;/tt&gt; evaluates a single object that is stored in scope. Like &lt;tt&gt;ImplicitObjectELResolver&lt;/tt&gt;, it also
only evaluates expressions with a base of &lt;tt&gt;null&lt;/tt&gt;. This resolver essentially looks for
an object in all of the scopes until it finds it, according to
the behavior of &lt;tt&gt;PageContext.findAttribute(String)&lt;/tt&gt;. For example, when evaluating the expression &lt;tt&gt;${product}&lt;/tt&gt;, the resolver
will look for &lt;tt&gt;product&lt;/tt&gt; in the page, request, session, and application scopes and
will return its value. If &lt;tt&gt;product&lt;/tt&gt; is not found, &lt;tt&gt;null&lt;/tt&gt; is returned.&lt;/p&gt;&lt;p&gt;When an expression references one of the implicit objects by name, the appropriate
object is returned instead of the corresponding attribute. For example, &lt;tt&gt;${pageContext}&lt;/tt&gt; returns the
&lt;tt&gt;PageContext&lt;/tt&gt; object, even if there is an existing &lt;tt&gt;pageContext&lt;/tt&gt; attribute containing some other value.&lt;a name="indexterm-361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;a name="bnaik"&gt;&lt;/a&gt;&lt;h4&gt;Operators&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-362"&gt;&lt;/a&gt;In addition to the &lt;tt&gt;.&lt;/tt&gt; and &lt;tt&gt;[]&lt;/tt&gt; operators discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnahu"&gt;Value and Method Expressions&lt;/a&gt;, the JSP expression
language provides the following operators, which can be used in rvalue expressions only:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;b&gt;Arithmetic&lt;/b&gt;: &lt;tt&gt;+&lt;/tt&gt;, &lt;tt&gt;-&lt;/tt&gt; (binary), &lt;tt&gt;*&lt;/tt&gt;, &lt;tt&gt;/&lt;/tt&gt; and &lt;tt&gt;div&lt;/tt&gt;, &lt;tt&gt;%&lt;/tt&gt; and &lt;tt&gt;mod&lt;/tt&gt;, &lt;tt&gt;-&lt;/tt&gt; (unary)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Logical&lt;/b&gt;: &lt;tt&gt;and&lt;/tt&gt;, &lt;tt&gt;&amp;amp;&amp;amp;&lt;/tt&gt;, &lt;tt&gt;or&lt;/tt&gt;, &lt;tt&gt;||&lt;/tt&gt;, &lt;tt&gt;not&lt;/tt&gt;, &lt;tt&gt;!&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Relational&lt;/b&gt;: &lt;tt&gt;==&lt;/tt&gt;, &lt;tt&gt;eq&lt;/tt&gt;, &lt;tt&gt;!=&lt;/tt&gt;, &lt;tt&gt;ne&lt;/tt&gt;, &lt;tt&gt;&amp;lt;&lt;/tt&gt;, &lt;tt&gt;lt&lt;/tt&gt;, &lt;tt&gt;&amp;gt;&lt;/tt&gt;, &lt;tt&gt;gt&lt;/tt&gt;, &lt;tt&gt;&amp;lt;=&lt;/tt&gt;, &lt;tt&gt;ge&lt;/tt&gt;, &lt;tt&gt;&amp;gt;=&lt;/tt&gt;, &lt;tt&gt;le&lt;/tt&gt;. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Empty&lt;/b&gt;: The &lt;tt&gt;empty&lt;/tt&gt; operator is a prefix operation that can be used to determine whether a value is &lt;tt&gt;null&lt;/tt&gt; or empty.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Conditional&lt;/b&gt;: &lt;tt&gt;A ? B : C&lt;/tt&gt;. Evaluate &lt;tt&gt;B&lt;/tt&gt; or &lt;tt&gt;C&lt;/tt&gt;, depending on the result of the evaluation of &lt;tt&gt;A&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The precedence of operators highest to lowest, left to right is as
follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;tt&gt;[] .&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;()&lt;/tt&gt; (used to change the precedence of operators)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;-&lt;/tt&gt; (unary) &lt;tt&gt;not ! empty&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;* / div % mod&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;+ -&lt;/tt&gt; (binary)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= lt gt le ge&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;== != eq ne&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;&amp;amp;&amp;amp; and&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;|| or&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;tt&gt;? :&lt;/tt&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnail"&gt;&lt;/a&gt;&lt;h4&gt;Reserved Words&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-363"&gt;&lt;/a&gt;The following words are reserved for the JSP expression language and should not
be used as identifiers.&lt;/p&gt;&lt;table ID="Table4"&gt;&lt;col width="25*"&gt;&lt;col width="25*"&gt;&lt;col width="25*"&gt;&lt;col width="25*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;and&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;or&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;not&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;eq&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ne&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;lt&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;gt&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;le&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;ge&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;null&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;instanceof&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;empty&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;div&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;mod&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Note that many of these words are not in the language now,
but they may be in the future, so you should avoid using them.&lt;/p&gt;

&lt;a name="bnaim"&gt;&lt;/a&gt;&lt;h4&gt;Examples of EL Expressions&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-364"&gt;&lt;/a&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnain"&gt;Table 5-5&lt;/a&gt; contains example EL expressions and the result of evaluating them.&lt;/p&gt;&lt;a name="bnain"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-5 Example Expressions&lt;/h6&gt;&lt;table ID="Table5"&gt;&lt;col width="150*"&gt;&lt;col width="204*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;EL Expression&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Result&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${1 &amp;gt; (4/2)}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${4.0 &amp;gt;= 3}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${100.0 == 100}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${(10*10) ne 100}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${&amp;#8216;a&amp;#8216; &amp;lt; &amp;#8216;b&amp;#8216;}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${&amp;#8216;hip&amp;#8216; gt &amp;#8216;hit&amp;#8216;}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${4 &amp;gt; 3}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${1.2E4 + 1.4}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;12001.4&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${3 div 4}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;0.75&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${10 mod 4}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;2&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${!empty param.Add}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;False if
the request parameter named &lt;tt&gt;Add&lt;/tt&gt; is null or an empty string.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${pageContext.request.contextPath}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The context path.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${sessionScope.cart.numberOfItems}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The
value of the &lt;tt&gt;numberOfItems&lt;/tt&gt; property of the session-scoped attribute named &lt;tt&gt;cart&lt;/tt&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${param[&amp;#8216;mycom.productId&amp;#8216;]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The value of
the request parameter named &lt;tt&gt;mycom.productId&lt;/tt&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${header["host"]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The host.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${departments[deptName]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The value of the entry named &lt;tt&gt;deptName&lt;/tt&gt;
in the &lt;tt&gt;departments&lt;/tt&gt; map.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;${requestScope[’javax.servlet.forward.servlet_path’]}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The value of the request-scoped attribute named &lt;tt&gt;javax.servlet.forward.servlet_path&lt;/tt&gt;.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;#{customer.lName}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Gets the
value of the property &lt;tt&gt;lName&lt;/tt&gt; from the &lt;tt&gt;customer&lt;/tt&gt; bean during an initial
request. Sets the value of &lt;tt&gt;lName&lt;/tt&gt; during a postback.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;#{customer.calcTotal}&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;The return value of the
method &lt;tt&gt;calcTotal&lt;/tt&gt; of the &lt;tt&gt;customer&lt;/tt&gt; bean.&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;a name="bnaio"&gt;&lt;/a&gt;&lt;h4&gt;Functions&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-365"&gt;&lt;/a&gt;The JSP expression language allows you to define a function that can be
invoked in an expression. Functions are defined using the same mechanisms as custom
tags (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaiy.html"&gt;Using Custom Tags&lt;/a&gt; and &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;At first glance, functions seem similar to method expressions, but they are different
in the following ways:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Functions refer to static methods that return a value.
Method expressions refer to non-static, arbitrary public methods on
objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functions are identified statically at translation time, whereas methods are identified dynamically at runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Function parameters and invocations are specified as part of an
EL expression. A method expression only identifies a particular method.
The invocation of that method is not specified by the EL expression;
rather, it is specified in the tag attribute definition of the
attribute using the method expression, as described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnaia"&gt;Defining a Tag Attribute Type&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;a name="bnaip"&gt;&lt;/a&gt;&lt;h5&gt;Using Functions&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-366"&gt;&lt;/a&gt;Functions can appear in static text and tag attribute values.&lt;/p&gt;&lt;p&gt;To use a function in a JSP page, you use a &lt;tt&gt;taglib&lt;/tt&gt;
directive to import the tag library containing the function. Then you preface the
function invocation with the prefix declared in the directive.&lt;/p&gt;&lt;p&gt;For example, the date example page &lt;tt&gt;index.jsp&lt;/tt&gt; imports the &lt;tt&gt;/functions&lt;/tt&gt; library and invokes
the function &lt;tt&gt;equals&lt;/tt&gt; in an expression:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ taglib prefix="f" uri="/functions"%&amp;gt;
...
        &amp;lt;c:when
            test="${f:equals(selectedLocaleString,
                localeString)}" &amp;gt;&lt;/pre&gt;&lt;p&gt;In this example, the expression referencing the function is using immediate evaluation syntax.
A page author can also use deferred evaluation syntax to reference a function
in an expression, assuming that the attribute that is referencing the function can
accept deferred expressions.&lt;/p&gt;&lt;p&gt;If an attribute references a function with a deferred expression then the function
is not invoked immediately; rather, it is invoked whenever the underlying technology using
the function determines it should be invoked.&lt;/p&gt;

&lt;a name="bnaiq"&gt;&lt;/a&gt;&lt;h5&gt;Defining Functions&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-367"&gt;&lt;/a&gt;To define a function, program it as a public static method in a
public class. The &lt;tt&gt;mypkg.MyLocales&lt;/tt&gt; class in the &lt;tt&gt;date&lt;/tt&gt; example defines a function that
tests the equality of two &lt;tt&gt;String&lt;/tt&gt;s as follows:&lt;/p&gt;&lt;pre&gt;package mypkg;
public class MyLocales {

    ...
    public static boolean equals( String l1, String l2 ) {
        return l1.equals(l2);
    }
}&lt;/pre&gt;&lt;p&gt;Then map the function name as used in the EL expression to
the defining class and function signature in a TLD (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;). The following
&lt;tt&gt;functions.tld&lt;/tt&gt; file in the date example maps the &lt;tt&gt;equals&lt;/tt&gt; function to the class containing
the implementation of the function &lt;tt&gt;equals&lt;/tt&gt; and the signature of the function:&lt;/p&gt;&lt;pre&gt;&amp;lt;function&amp;gt;
    &amp;lt;name&amp;gt;equals&amp;lt;/name&amp;gt;
    &amp;lt;function-class&amp;gt;mypkg.MyLocales&amp;lt;/function-class&amp;gt;
    &amp;lt;function-signature&amp;gt;boolean equals( java.lang.String,
        java.lang.String )&amp;lt;/function-signature&amp;gt;
&amp;lt;/function&amp;gt;&lt;/pre&gt;&lt;p&gt;No two functions within a tag library can have the same name.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="39314103659" hide="0">
			<date>January  20, 2008</date>
			<title>JavaBeans Components</title>
			<description>&lt;p&gt;JavaBeans components are Java classes that can be easily reused and composed together into
applications. Any Java class that follows certain design conventions is a JavaBeans component.&lt;/p&gt;&lt;p&gt;JavaServer Pages technology directly supports using JavaBeans components with standard JSP language elements.
You can easily create and initialize beans and get and set the values
of their properties.&lt;/p&gt;

&lt;a name="bnais"&gt;&lt;/a&gt;&lt;h4&gt;JavaBeans Component Design Conventions&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-370"&gt;&lt;/a&gt;JavaBeans component design conventions govern the properties of the class and govern the
public methods that give access to the properties.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-371"&gt;&lt;/a&gt;A JavaBeans component property can be:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Read/write, read-only, or write-only&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simple, which means it contains a single value, or indexed, which means it represents an array of values&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-372"&gt;&lt;/a&gt;A property does not have to be implemented by an instance variable. It
must simply be accessible using public methods that conform to the following conventions:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;For each readable property, the bean must have a method of the form:&lt;/p&gt;&lt;pre&gt;PropertyClass getProperty() { ... }&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For each writable property, the bean must have a method of the form:&lt;/p&gt;&lt;pre&gt;setProperty(PropertyClass pc) { ... }&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In addition to the property methods, a JavaBeans component must define a constructor
that takes no parameters.&lt;/p&gt;&lt;p&gt;The Duke’s Bookstore application JSP pages &lt;tt&gt;bookstore.jsp&lt;/tt&gt;, &lt;tt&gt;bookdetails.jsp&lt;/tt&gt;, &lt;tt&gt;catalog.jsp&lt;/tt&gt;, and &lt;tt&gt;showcart.jsp&lt;/tt&gt;, all
located at &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/web&lt;/tt&gt;, use the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/src/java/com/sun/bookstore2/database/BookDB.java&lt;/tt&gt; JavaBeans component.&lt;/p&gt;&lt;p&gt;&lt;tt&gt;BookDB&lt;/tt&gt; provides a JavaBeans component front end to the access object &lt;tt&gt;BookDBAO&lt;/tt&gt;. The
JSP pages &lt;tt&gt;showcart.jsp&lt;/tt&gt; and &lt;tt&gt;cashier.jsp&lt;/tt&gt; access the bean &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore/src/com/sun/bookstore/cart/ShoppingCart.java&lt;/tt&gt;, which represents a
user’s shopping cart.&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;BookDB&lt;/tt&gt; bean has two writable properties, &lt;tt&gt;bookId&lt;/tt&gt; and &lt;tt&gt;database&lt;/tt&gt;, and three
readable properties: &lt;tt&gt;bookDetails&lt;/tt&gt;, &lt;tt&gt;numberOfBooks&lt;/tt&gt;, and &lt;tt&gt;books&lt;/tt&gt;. These latter properties do not correspond to
any instance variables but rather are a function of the &lt;tt&gt;bookId&lt;/tt&gt; and &lt;tt&gt;database&lt;/tt&gt;
properties.&lt;/p&gt;&lt;pre&gt;package database;
public class BookDB {
    private String bookId = "0";
    private BookDBAO database = null;
    public BookDB () {
    }
    public void setBookId(String bookId) {
    this.bookId = bookId;
    }
    public void setDatabase(BookDBAO database) {
    this.database = database;
    }
    public Book getBook() throws
         BookNotFoundException {
        return (Book)database.getBook(bookId);
     }
    public List getBooks() throws BooksNotFoundException {
        return database.getBooks();
    }
    public void buyBooks(ShoppingCart cart)
         throws OrderException {
        database.buyBooks(cart);
    }
    public int getNumberOfBooks() throws BooksNotFoundException {
        return database.getNumberOfBooks();
    }
}&lt;a name="indexterm-373"&gt;&lt;/a&gt;&lt;/pre&gt;

&lt;a name="bnait"&gt;&lt;/a&gt;&lt;h4&gt;Creating and Using a JavaBeans Component&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-374"&gt;&lt;/a&gt;&lt;a name="indexterm-375"&gt;&lt;/a&gt;To declare that your JSP page will use a JavaBeans component, you use
a &lt;tt&gt;jsp:useBean&lt;/tt&gt; element. There are two forms:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:useBean id="&lt;i&gt;beanName&lt;/i&gt;"
    class="&lt;i&gt;fully-qualified-classname&lt;/i&gt;" scope="&lt;i&gt;scope&lt;/i&gt;"/&amp;gt;&lt;/pre&gt;&lt;p&gt;and&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:useBean id="&lt;i&gt;beanName&lt;/i&gt;"
    class="&lt;i&gt;fully-qualified-classname&lt;/i&gt;" scope="&lt;i&gt;scope&lt;/i&gt;"&amp;gt;
    &amp;lt;jsp:setProperty .../&amp;gt;
&amp;lt;/jsp:useBean&amp;gt;&lt;/pre&gt;&lt;p&gt;The second form is used when you want to include &lt;tt&gt;jsp:setProperty&lt;/tt&gt; statements, described
in the next section, for initializing bean properties.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-376"&gt;&lt;/a&gt;&lt;a name="indexterm-377"&gt;&lt;/a&gt;The &lt;tt&gt;jsp:useBean&lt;/tt&gt; element declares that the page will use a bean that
is stored within and is accessible from the specified scope, which can be
&lt;tt&gt;application&lt;/tt&gt;, &lt;tt&gt;session&lt;/tt&gt;, &lt;tt&gt;request&lt;/tt&gt;, or &lt;tt&gt;page&lt;/tt&gt;. If no such bean exists, the statement creates
the bean and stores it as an attribute of the scope object (see
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnafo.html#bnafp"&gt;Using Scope Objects&lt;/a&gt;). The value of the &lt;tt&gt;id&lt;/tt&gt; attribute determines the &lt;b&gt;name&lt;/b&gt; of the bean in
the scope and the &lt;b&gt;identifier&lt;/b&gt; used to reference the bean in EL expressions,
other JSP elements, and scripting expressions (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaon.html"&gt;Chapter 9, Scripting in JSP Pages&lt;/a&gt;). The value supplied for the &lt;tt&gt;class&lt;/tt&gt;
attribute must be a fully qualified class name. Note that beans cannot be
in the unnamed package. Thus the format of the value must be &lt;i&gt;package-name.class-name&lt;/i&gt;.&lt;/p&gt;&lt;p&gt;The following element creates an instance of &lt;tt&gt;mypkg.myLocales&lt;/tt&gt; if none exists, stores it
as an attribute of the application scope, and makes the bean available throughout
the application by the identifier &lt;tt&gt;locales&lt;/tt&gt;:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:useBean id="locales" scope="application"
    class="mypkg.MyLocales"/&amp;gt;&lt;/pre&gt;

&lt;a name="bnaiu"&gt;&lt;/a&gt;&lt;h4&gt;Setting JavaBeans Component Properties&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-378"&gt;&lt;/a&gt;&lt;a name="indexterm-379"&gt;&lt;/a&gt;&lt;a name="indexterm-380"&gt;&lt;/a&gt;The standard way to set JavaBeans component properties in a JSP page is
by using the &lt;tt&gt;jsp:setProperty&lt;/tt&gt; element. The syntax of the &lt;tt&gt;jsp:setProperty&lt;/tt&gt; element depends on
the source of the property value. &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html#bnaiv"&gt;Table 5-6&lt;/a&gt; summarizes the various ways to set a
property of a JavaBeans component using the &lt;tt&gt;jsp:setProperty&lt;/tt&gt; element.&lt;/p&gt;
&lt;hr&gt;&lt;p&gt;&lt;b&gt;Note - &lt;/b&gt;&lt;/p&gt;&lt;p&gt;Syntax rules of attribute values used in this table:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;i&gt;beanName&lt;/i&gt; must be the same as that specified for the  &lt;tt&gt;id&lt;/tt&gt; attribute in a  &lt;tt&gt;useBean&lt;/tt&gt; element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There must be a &lt;i&gt;setPropName&lt;/i&gt; method in the JavaBeans component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;i&gt;paramName&lt;/i&gt; must be a request parameter name.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;hr&gt;
&lt;a name="bnaiv"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-6 Valid Bean Property Assignments from String Values&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="115*"&gt;&lt;col width="240*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Value Source&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Element Syntax&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;String constant&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="&lt;i&gt;propName&lt;/i&gt;" value="&lt;i&gt;string-constant&lt;/i&gt;"/&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Request parameter&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="&lt;i&gt;propName&lt;/i&gt;" param="&lt;i&gt;paramName&lt;/i&gt;"/&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Request parameter name that matches bean property&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="&lt;i&gt;propName&lt;/i&gt;"/&amp;gt;
&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="*"/&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Expression&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;pre&gt;&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="&lt;i&gt;propName&lt;/i&gt;" value="&lt;i&gt;expression&lt;/i&gt;"/&amp;gt;
&amp;lt;jsp:setProperty name="&lt;i&gt;beanName&lt;/i&gt;"
   property="&lt;i&gt;propName&lt;/i&gt;" &amp;gt;
   &amp;lt;jsp:attribute name="value"&amp;gt;
      &lt;i&gt;expression&lt;/i&gt;
   &amp;lt;/jsp:attribute&amp;gt;
&amp;lt;/jsp:setProperty&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a name="indexterm-381"&gt;&lt;/a&gt;&lt;a name="indexterm-382"&gt;&lt;/a&gt;&lt;a name="indexterm-383"&gt;&lt;/a&gt;&lt;a name="indexterm-384"&gt;&lt;/a&gt;A property set from a constant string or request parameter must have one
of the types listed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html#bnaiw"&gt;Table 5-7&lt;/a&gt;. Because constants and request parameters are strings,
the web container automatically converts the value to the property’s type; the conversion
applied is shown in the table.&lt;/p&gt;&lt;p&gt;&lt;tt&gt;String&lt;/tt&gt; values can be used to assign values to a property that has
a &lt;tt&gt;PropertyEditor&lt;/tt&gt; class. When that is the case, the &lt;tt&gt;setAsText(String)&lt;/tt&gt; method is used.
A conversion failure arises if the method throws an &lt;tt&gt;IllegalArgumentException&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;The value assigned to an indexed property must be an array, and
the rules just described apply to the elements.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-385"&gt;&lt;/a&gt;&lt;a name="indexterm-386"&gt;&lt;/a&gt;You use an expression to set the value of a property whose type
is a compound Java programming language type. The type returned from an expression
must match or be castable to the type of the property.&lt;/p&gt;&lt;a name="bnaiw"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-7 Valid Property Value Assignments from String Values&lt;/h6&gt;&lt;table ID="Table2"&gt;&lt;col width="102*"&gt;&lt;col width="252*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Property Type&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Conversion
on String Value&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Bean Property&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Uses &lt;tt&gt;setAsText(&lt;/tt&gt;&lt;i&gt;string-literal&lt;/i&gt;&lt;tt&gt;)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;boolean&lt;/tt&gt; or &lt;tt&gt;Boolean&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.Boolean.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;byte&lt;/tt&gt; or &lt;tt&gt;Byte&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As
indicated in &lt;tt&gt;java.lang.Byte.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;char&lt;/tt&gt; or &lt;tt&gt;Character&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.String.charAt(0)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;double&lt;/tt&gt; or &lt;tt&gt;Double&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in
&lt;tt&gt;java.lang.Double.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;int&lt;/tt&gt; or &lt;tt&gt;Integer&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.Integer.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;float&lt;/tt&gt; or &lt;tt&gt;Float&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.Float.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;long&lt;/tt&gt; or
&lt;tt&gt;Long&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.Long.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;short&lt;/tt&gt; or &lt;tt&gt;Short&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;As indicated in &lt;tt&gt;java.lang.Short.valueOf(String)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;Object&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;new &lt;tt&gt;String(&lt;/tt&gt;&lt;i&gt;string-literal&lt;/i&gt;&lt;tt&gt;)&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;The Duke’s Bookstore application demonstrates how to use the &lt;tt&gt;setProperty&lt;/tt&gt; element to
set the current book from a request parameter in the database bean in
&lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/web/books/bookdetails.jsp&lt;/tt&gt;:&lt;/p&gt;&lt;pre&gt;&amp;lt;c:set var="bid" value="${param.bookId}"/&amp;gt;
&amp;lt;jsp:setProperty name="bookDB" property="bookId"
    value="${bid}" /&amp;gt;&lt;/pre&gt;&lt;p&gt;The following fragment from the page &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore2/web/books/bookshowcart.jsp&lt;/tt&gt; illustrates how to initialize a
&lt;tt&gt;BookDB&lt;/tt&gt; bean with a &lt;tt&gt;database&lt;/tt&gt; object. Because the initialization is nested in a &lt;tt&gt;useBean&lt;/tt&gt;
element, it is executed only when the bean is created.&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:useBean id="bookDB" class="database.BookDB" scope="page"&amp;gt;
    &amp;lt;jsp:setProperty name="bookDB" property="database"
         value="${bookDBAO}" /&amp;gt;
&amp;lt;/jsp:useBean&amp;gt;&lt;/pre&gt;

&lt;a name="bnaix"&gt;&lt;/a&gt;&lt;h4&gt;Retrieving JavaBeans Component Properties&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-387"&gt;&lt;/a&gt;&lt;a name="indexterm-388"&gt;&lt;/a&gt;The main way to retrieve JavaBeans component properties is by using the unified
EL expressions. Thus, to retrieve a book title, the Duke’s Bookstore application uses
the following expression:&lt;/p&gt;&lt;pre&gt;${bookDB.bookDetails.title}&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-389"&gt;&lt;/a&gt;Another way to retrieve component properties is to use the &lt;tt&gt;jsp:getProperty&lt;/tt&gt; element.
This element converts the value of the property into a &lt;tt&gt;String&lt;/tt&gt; and
inserts the value into the response stream:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:getProperty name="&lt;i&gt;beanName&lt;/i&gt;" property="&lt;i&gt;propName&lt;/i&gt;"/&amp;gt;&lt;/pre&gt;&lt;p&gt;Note that &lt;i&gt;beanName&lt;/i&gt; must be the same as that specified for the &lt;tt&gt;id&lt;/tt&gt;
attribute in a &lt;tt&gt;useBean&lt;/tt&gt; element, and there must be a &lt;tt&gt;get&lt;i&gt;PropName&lt;/i&gt;&lt;/tt&gt; method in the
JavaBeans component. Although the preferred approach to getting properties is to use an
EL expression, the &lt;tt&gt;getProperty&lt;/tt&gt; element is available if you need to disable expression
evaluation.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="46164132035" hide="0">
			<date>January  20, 2008</date>
			<title>Using Custom Tags</title>
			<description>&lt;p&gt;&lt;b&gt;Custom tags&lt;/b&gt; are user-defined JSP language elements that encapsulate recurring tasks. Custom tags are
distributed in a &lt;b&gt;tag library&lt;/b&gt;, which defines a set of related custom tags
and contains the objects that implement the tags.&lt;/p&gt;&lt;p&gt;Custom tags have the syntax&lt;/p&gt;&lt;pre&gt;&amp;lt;prefix:tag attr1="value" ... attrN="value" /&amp;gt;&lt;/pre&gt;&lt;p&gt;or&lt;/p&gt;&lt;pre&gt;&amp;lt;prefix:tag attr1="value" ... attrN="value" &amp;gt;
     &lt;i&gt;body&lt;/i&gt;&amp;lt;/prefix:tag&amp;gt;&lt;/pre&gt;&lt;p&gt;where &lt;tt&gt;prefix&lt;/tt&gt; distinguishes tags for a library, &lt;tt&gt;tag&lt;/tt&gt; is the tag identifier,
and &lt;tt&gt;attr1 ... attrN&lt;/tt&gt; are attributes that modify the behavior of the tag.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-390"&gt;&lt;/a&gt;To use a custom tag in a JSP page, you must&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Declare the tag library containing the tag&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the tag library implementation available to the web application&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt; for detailed information on the different types of tags and how
to implement tags.&lt;/p&gt;

&lt;a name="bnaiz"&gt;&lt;/a&gt;&lt;h4&gt;Declaring Tag Libraries&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-391"&gt;&lt;/a&gt;&lt;a name="indexterm-392"&gt;&lt;/a&gt;To declare that a JSP page will use tags defined in a
tag library, you include a &lt;tt&gt;taglib&lt;/tt&gt; directive in the page before any custom tag
from that tag library is used. If you forget to include the
&lt;tt&gt;taglib&lt;/tt&gt; directive for a tag library in a JSP page, the JSP compiler
will treat any invocation of a custom tag from that library as static
data and will simply insert the text of the custom tag call into
the response.&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ taglib prefix="tt" [tagdir=/WEB-INF/tags/&lt;i&gt;dir&lt;/i&gt; | uri=&lt;i&gt;URI&lt;/i&gt; ] %&amp;gt;&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;prefix&lt;/tt&gt; attribute defines the prefix that distinguishes tags defined by a given
tag library from those provided by other tag libraries.&lt;/p&gt;&lt;p&gt;If the tag library is defined with tag files (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html"&gt;Encapsulating Reusable Content Using Tag Files&lt;/a&gt;), you
supply the &lt;tt&gt;tagdir&lt;/tt&gt; attribute to identify the location of the files. The
value of the attribute must start with &lt;tt&gt;/WEB-INF/tags/&lt;/tt&gt;. A translation error will occur if
the value points to a directory that doesn’t exist or if it is
used in conjunction with the &lt;tt&gt;uri&lt;/tt&gt; attribute.&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;uri&lt;/tt&gt; attribute refers to a URI that uniquely identifies the tag library
descriptor (TLD), a document that describes the tag library (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnamu.html"&gt;Tag Library Descriptors&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-393"&gt;&lt;/a&gt;Tag library descriptor file names must have the extension &lt;tt&gt;.tld&lt;/tt&gt;. TLD files
are stored in the &lt;tt&gt;WEB-INF&lt;/tt&gt; directory or subdirectory of the WAR file, or
in the &lt;tt&gt;META-INF&lt;/tt&gt; directory or subdirectory of a tag library packaged in a
JAR. You can reference a TLD directly or indirectly.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-394"&gt;&lt;/a&gt;The following &lt;tt&gt;taglib&lt;/tt&gt; directive directly references a TLD file name:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ taglib prefix="tlt" uri="/WEB-INF/iterator.tld"%&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-395"&gt;&lt;/a&gt;This &lt;tt&gt;taglib&lt;/tt&gt; directive uses a short logical name to indirectly reference the TLD:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ taglib prefix="tlt" uri="/tlt"%&amp;gt;&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;iterator&lt;/tt&gt; example defines and uses a simple iteration tag. The JSP pages
use a logical name to reference the TLD.&lt;/p&gt;&lt;p&gt;To deploy and run the &lt;tt&gt;iterator&lt;/tt&gt; application with NetBeans IDE, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In NetBeans IDE, select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;iterator&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;iterator&lt;/tt&gt; project, and select Deploy Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the application, open the bookstore URL &lt;tt&gt;http://localhost:8080/iterator&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy and run the &lt;tt&gt;iterator&lt;/tt&gt; application with Ant, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/iterator/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This command will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/iterator/build/&lt;/tt&gt; directory, and create a WAR file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Application Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the example, open your browser to &lt;tt&gt;http://localhost:8080/iterator&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To learn how to configure the example, refer to the deployment descriptor, which
includes the following configurations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A &lt;tt&gt;display-name&lt;/tt&gt; element that specifies the name that tools use to identify the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nested inside a &lt;tt&gt;jsp-config&lt;/tt&gt; element is a &lt;tt&gt;taglib&lt;/tt&gt; element, which provides information on a tag library used by the pages of the application. Inside the &lt;tt&gt;taglib&lt;/tt&gt; element are the &lt;tt&gt;taglib-uri&lt;/tt&gt; element and the &lt;tt&gt;taglib-location&lt;/tt&gt; element. The &lt;tt&gt;taglib-uri&lt;/tt&gt; element identifies the logical name of the tag library. The &lt;tt&gt;taglib-location&lt;/tt&gt; element gives the absolute location or the absolute URI of the tag library.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The absolute URIs for the JSTL library are as follows:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;b&gt;Core&lt;/b&gt;: &lt;a href="http://java.sun.com/jsp/jstl/core"&gt;http://java.sun.com/jsp/jstl/core&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;XML&lt;/b&gt;: &lt;a href="http://java.sun.com/jsp/jstl/xml"&gt;http://java.sun.com/jsp/jstl/xml&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Internationalization&lt;/b&gt;: &lt;a href="http://java.sun.com/jsp/jstl/fmt"&gt;http://java.sun.com/jsp/jstl/fmt&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;SQL&lt;/b&gt;: &lt;a href="http://java.sun.com/jsp/jstl/sql"&gt;http://java.sun.com/jsp/jstl/sql&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Functions&lt;/b&gt;: &lt;a href="http://java.sun.com/jsp/jstl/functions"&gt;http://java.sun.com/jsp/jstl/functions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-396"&gt;&lt;/a&gt;When you reference a tag library with an absolute URI that exactly matches
the URI declared in the &lt;tt&gt;taglib&lt;/tt&gt; element of the TLD (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnamu.html"&gt;Tag Library Descriptors&lt;/a&gt;), you do
not have to add the &lt;tt&gt;taglib&lt;/tt&gt; element to &lt;tt&gt;web.xml&lt;/tt&gt;; the JSP container
automatically locates the TLD inside the JSTL library implementation.&lt;/p&gt;

&lt;a name="bnaja"&gt;&lt;/a&gt;&lt;h4&gt;Including the Tag Library Implementation&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-397"&gt;&lt;/a&gt;&lt;a name="indexterm-398"&gt;&lt;/a&gt;In addition to declaring the tag library, you also must make the tag
library implementation available to the web application. There are several ways to do
this. Tag library implementations can be included in a WAR in an unpacked
format: Tag files are packaged in the &lt;tt&gt;/WEB-INF/tag/&lt;/tt&gt; directory, and tag handler classes
are packaged in the &lt;tt&gt;/WEB-INF/classes/&lt;/tt&gt; directory of the WAR. Tag libraries already packaged
into a JAR file are included in the &lt;tt&gt;/WEB-INF/lib/&lt;/tt&gt; directory of the WAR.
Finally, an application server can load a tag library into all the web
applications running on the server. For example, in the Application Server, the JSTL
TLDs and libraries are distributed in the archive &lt;tt&gt;appserv-jstl.jar&lt;/tt&gt; in &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;as-install&lt;/i&gt;&lt;tt&gt;/lib/&lt;/tt&gt;. This library
is automatically loaded into the classpath of all web applications running on the
Application Server, so you don’t need to add it to your web application.&lt;/p&gt;&lt;p&gt;The &lt;tt&gt;iterator&lt;/tt&gt; tag library is implemented with tag handlers. Therefore, its implementation classes
are packaged in the &lt;tt&gt;/WEB-INF/classes/&lt;/tt&gt; directory.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="16887124159" hide="0">
			<date>January  20, 2008</date>
			<title>Reusing Content in JSP Pages</title>
			<description>&lt;p&gt;There are many mechanisms for reusing JSP content in a JSP page. Three
mechanisms that can be categorized as direct reuse are discussed here:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;The &lt;tt&gt;include&lt;/tt&gt; directive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Preludes and codas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;tt&gt;jsp:include&lt;/tt&gt; element&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;An indirect method of content reuse occurs when a tag file is
used to define a custom tag that is used by many web applications.
Tag files are discussed in the section &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html"&gt;Encapsulating Reusable Content Using Tag Files&lt;/a&gt; in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html"&gt;Chapter 8, Custom Tags in JSP Pages&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-400"&gt;&lt;/a&gt;The &lt;tt&gt;include&lt;/tt&gt; directive is processed when the JSP page is &lt;b&gt;translated&lt;/b&gt; into a
servlet class. The effect of the directive is to insert the text contained
in another file (either static content or another JSP page) into the including
JSP page. You would probably use the &lt;tt&gt;include&lt;/tt&gt; directive to include banner content,
copyright information, or any chunk of content that you might want to reuse
in another page. The syntax for the &lt;tt&gt;include&lt;/tt&gt; directive is as follows:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ include file="filename" %&amp;gt;&lt;/pre&gt;&lt;p&gt;For example, all the Duke’s Bookstore application pages could include the file &lt;tt&gt;banner.jspf&lt;/tt&gt;,
which contains the banner content, by using the following directive:&lt;/p&gt;&lt;pre&gt;&amp;lt;%@ include file="banner.jspf" %&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a name="indexterm-401"&gt;&lt;/a&gt;Another way to do a static include is to use the prelude
and coda mechanisms described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html#bnajl"&gt;Defining Implicit Includes&lt;/a&gt;. This is the approach used by the Duke’s
Bookstore application.&lt;/p&gt;&lt;p&gt;Because you must put an &lt;tt&gt;include&lt;/tt&gt; directive in each file that reuses the
resource referenced by the directive, this approach has its limitations. Preludes and codas
can be applied only to the beginnings and ends of pages. For a
more flexible approach to building pages out of content chunks, see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnann.html#bnaoh"&gt;A Template Tag Library&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-402"&gt;&lt;/a&gt;The &lt;tt&gt;jsp:include&lt;/tt&gt; element is processed when a JSP page is &lt;b&gt;executed&lt;/b&gt;. The &lt;tt&gt;include&lt;/tt&gt;
action allows you to include either a static or a dynamic resource in
a JSP file. The results of including static and dynamic resources are quite
different. If the resource is static, its content is inserted into the calling
JSP file. If the resource is dynamic, the request is sent to the
included resource, the included page is executed, and then the result is included
in the response from the calling JSP page. The syntax for the &lt;tt&gt;jsp:include&lt;/tt&gt;
element is:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:include page="includedPage" /&amp;gt;&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;hello1&lt;/tt&gt; application discussed in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnadx.html#bnadz"&gt;Packaging Web Modules&lt;/a&gt; uses the following statement to include the
page that generates the response:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:include page="response.jsp"/&amp;gt;&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="24456764827" hide="0">
			<date>January  20, 2008</date>
			<title>Transferring Control to Another Web Component</title>
			<description>&lt;p&gt;The mechanism for transferring control to another web component from a JSP page
uses the functionality provided by the Java Servlet API as described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagm.html#bnagn"&gt;Accessing a Session&lt;/a&gt;. You
access this functionality from a JSP page by using the &lt;tt&gt;jsp:forward&lt;/tt&gt; element:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:forward page="/main.jsp" /&amp;gt;&lt;/pre&gt;&lt;p&gt;Note that if any data has already been returned to a client,
the &lt;tt&gt;jsp:forward&lt;/tt&gt; element will fail with an &lt;tt&gt;IllegalStateException&lt;/tt&gt;.&lt;/p&gt;

&lt;a name="bnajd"&gt;&lt;/a&gt;&lt;h4&gt;&lt;tt&gt;jsp:param&lt;/tt&gt; Element&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-405"&gt;&lt;/a&gt;&lt;a name="indexterm-406"&gt;&lt;/a&gt;When an &lt;tt&gt;include&lt;/tt&gt; or &lt;tt&gt;forward&lt;/tt&gt; element is invoked, the original request object is
provided to the target page. If you wish to provide additional data to
that page, you can append parameters to the request object by using the
&lt;tt&gt;jsp:param&lt;/tt&gt; element:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:include page="..." &amp;gt;
    &amp;lt;jsp:param name="param1" value="value1"/&amp;gt;
&amp;lt;/jsp:include&amp;gt;&lt;/pre&gt;&lt;p&gt;When &lt;tt&gt;jsp:include&lt;/tt&gt; or &lt;tt&gt;jsp:forward&lt;/tt&gt; is executed, the included page or forwarded page will
see the original request object, with the original parameters augmented with the new
parameters and new values taking precedence over existing values when applicable. For example, if
the request has a parameter &lt;tt&gt;A=foo&lt;/tt&gt; and a parameter &lt;tt&gt;A=bar&lt;/tt&gt; is specified
for forward, the forwarded request will have &lt;tt&gt;A=bar,foo&lt;/tt&gt;. Note that the new
parameter has precedence.&lt;/p&gt;&lt;p&gt;The scope of the new parameters is the &lt;tt&gt;jsp:include&lt;/tt&gt; or &lt;tt&gt;jsp:forward&lt;/tt&gt; call;
that is, in the case of an &lt;tt&gt;jsp:include&lt;/tt&gt; the new parameters (and values)
will not apply after the include.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="47970549310" hide="0">
			<date>January  20, 2008</date>
			<title>Setting Properties for Groups of JSP Pages</title>
			<description>&lt;p&gt;It is possible to specify certain properties for a group of JSP pages:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;Expression language evaluation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Treatment of scripting elements (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaoq.html"&gt;Disabling Scripting&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Page encoding&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic prelude and coda includes&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-413"&gt;&lt;/a&gt;A JSP property group is defined by naming the group and specifying one
or more URL patterns; all the properties in the group apply to the
resources that match any of the URL patterns. If a resource matches URL
patterns in more than one group, the pattern that is most specific applies.
&lt;/p&gt;&lt;p&gt;To define a property group in a deployment descriptor using NetBeans IDE, follow
these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In NetBeans IDE, expand your project’s folder in the Projects pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt; to open it in the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Pages at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Add JSP Property Group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Add JSP Property Group dialog:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Enter a name for the JSP property group in the Display Name field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a URL pattern (a regular expression, such as &lt;tt&gt;*.jsp&lt;/tt&gt;) or click Browse to indicate to which page or set of pages to apply the properties specified by the JSP property group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click OK.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Instead of performing the preceding steps, you can define a JSP property group
by editing the XML by hand using NetBeans IDE by doing the
following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Perform steps 1 through 3 in the preceding set of steps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click XML at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include a &lt;tt&gt;jsp-config&lt;/tt&gt; element if the deployment descriptor doesn’t already have one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a &lt;tt&gt;jsp-property-group&lt;/tt&gt; element inside the &lt;tt&gt;jsp-config&lt;/tt&gt; element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a &lt;tt&gt;display-name&lt;/tt&gt; element inside the &lt;tt&gt;jsp-property-group&lt;/tt&gt; element and give it a name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a &lt;tt&gt;url-pattern&lt;/tt&gt; element inside the &lt;tt&gt;jsp-property-group&lt;/tt&gt; element and give it a URL pattern (a regular expression, such as &lt;tt&gt;*.jsp&lt;/tt&gt;).&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The following sections discuss the properties and explain how they are interpreted for
various combinations of group properties, individual page directives, and web application deployment descriptor
versions.&lt;/p&gt;

&lt;a name="bnajh"&gt;&lt;/a&gt;&lt;h4&gt;Deactivating EL Expression Evaluation&lt;/h4&gt;
&lt;p&gt;&lt;a name="indexterm-414"&gt;&lt;/a&gt;Each JSP page has a default mode for EL expression evaluation. The default
value varies depending on the version of the web application deployment descriptor. The
default mode for JSP pages delivered with a Servlet 2.4 descriptor is to
evaluate EL expressions; this automatically provides the default that most applications want. The
default mode for JSP pages delivered using a descriptor from Servlet 2.3 or
before is to ignore EL expressions; this provides backward compatibility. For tag files (see
&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html"&gt;Encapsulating Reusable Content Using Tag Files&lt;/a&gt;), the default is to always evaluate expressions.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-415"&gt;&lt;/a&gt;You can override the default mode through the &lt;tt&gt;isELIgnored&lt;/tt&gt; attribute of the
&lt;tt&gt;page&lt;/tt&gt; directive in JSP pages and through the &lt;tt&gt;isELIgnored&lt;/tt&gt; attribute of the &lt;tt&gt;tag&lt;/tt&gt;
directive in tag files. You can also explicitly change the default mode by
doing one of the following:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;If you are using the Pages section of the &lt;tt&gt;web.xml&lt;/tt&gt; editor pane in NetBeans IDE:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the JSP Property Group node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Ignore Expression Language check box.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are editing the &lt;tt&gt;web.xml&lt;/tt&gt; file by hand, add  an &lt;tt&gt;el-ignored&lt;/tt&gt; element to the &lt;tt&gt;jsp-property-group&lt;/tt&gt; element in the deployment descriptor and set it to true.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html#bnaji"&gt;Table 5-8&lt;/a&gt; summarizes the EL evaluation settings for JSP pages.&lt;/p&gt;&lt;a name="bnaji"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-8 EL Evaluation Settings for JSP Pages&lt;/h6&gt;&lt;table ID="Table1"&gt;&lt;col width="100*"&gt;&lt;col width="105*"&gt;&lt;col width="146*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;JSP Configuration&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;Page Directive &lt;tt&gt;isELIgnored&lt;/tt&gt;&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;EL Encountered&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Unspecified&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Unspecified&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Evaluated
if 2.4 &lt;tt&gt;web.xml&lt;/tt&gt;&lt;/p&gt;&lt;p&gt;Ignored if &amp;lt;= 2.3 &lt;tt&gt;web.xml&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Unspecified&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Evaluated&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Unspecified&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Ignored&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Overridden by page directive&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Evaluated&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Overridden by page
directive&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Ignored&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html#bnajj"&gt;Table 5-9&lt;/a&gt; summarizes the EL evaluation settings for tag files.&lt;/p&gt;&lt;a name="bnajj"&gt;&lt;/a&gt;&lt;h6&gt;Table 5-9 EL Evaluation Settings for Tag Files&lt;/h6&gt;&lt;table ID="Table2"&gt;&lt;col width="184*"&gt;&lt;col width="170*"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left" valign="top"&gt;&lt;p&gt;Tag Directive  &lt;tt&gt;isELIgnored&lt;/tt&gt;&lt;/p&gt;&lt;/th&gt;
&lt;th align="left" valign="top"&gt;&lt;p&gt;EL Encountered&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;Unspecified&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Evaluated&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;false&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Evaluated&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;p&gt;&lt;tt&gt;true&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td align="left" valign="top"&gt;&lt;p&gt;Ignored&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;a name="bnajk"&gt;&lt;/a&gt;&lt;h5&gt;Declaring Page Encodings&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-416"&gt;&lt;/a&gt;You set the page encoding of a group of JSP pages using the
JSP property group configuration in the deployment descriptor by doing one of the
following:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;If you are using the Pages section of the &lt;tt&gt;web.xml&lt;/tt&gt; editor pane in NetBeans IDE:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Expand the JSP Property Group node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the page encoding in the Page Encoding field.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you are editing the &lt;tt&gt;web.xml&lt;/tt&gt; file by hand, add a &lt;tt&gt;page-encoding&lt;/tt&gt; element to the &lt;tt&gt;jsp-property-group&lt;/tt&gt;
element in the deployment descriptor and set it to one of the valid
character encoding codes, which are the same as those accepted by the &lt;tt&gt;pageEncoding&lt;/tt&gt; attribute of the &lt;tt&gt;page&lt;/tt&gt; directive.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;A translation-time error results if you define the page encoding of a JSP
page with one value in the JSP configuration element and then give
it a different value in a &lt;tt&gt;pageEncoding&lt;/tt&gt; directive.&lt;/p&gt;

&lt;a name="bnajl"&gt;&lt;/a&gt;&lt;h5&gt;Defining Implicit Includes&lt;/h5&gt;
&lt;p&gt;&lt;a name="indexterm-417"&gt;&lt;/a&gt;You can implicitly include preludes and codas for a group of JSP pages
by adding items to the Include Preludes and Codas lists. Their values are
context-relative paths that must correspond to elements in the web application. When the
elements are present, the given paths are automatically included (as in an &lt;tt&gt;include&lt;/tt&gt;
directive) at the beginning and end, respectively, of each JSP page in the
property group. When there is more than one include or coda element in
a group, they are included in the order they appear. When more than
one JSP property group applies to a JSP page, the corresponding elements will
be processed in the same order as they appear in the JSP configuration
section.&lt;/p&gt;&lt;p&gt;For example, the Duke’s Bookstore application uses the files &lt;tt&gt;/template/prelude.jspf&lt;/tt&gt; and &lt;tt&gt;/template/coda.jspf&lt;/tt&gt;
to include the banner and other boilerplate in each screen. To add these
files to the Duke’s Bookstore property group using the deployment descriptor, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In NetBeans IDE, expand your project’s folder in the Projects pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the Web Pages node and then the WEB-INF node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Double-click &lt;tt&gt;web.xml&lt;/tt&gt; to open it in the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Pages at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a new JSP property group if you haven’t already (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html"&gt;Setting Properties for Groups of JSP Pages&lt;/a&gt;) and give it the name &lt;tt&gt;bookstore2&lt;/tt&gt; and the URL pattern &lt;tt&gt;*.jsp&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand the JSP Property Group node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Browse button to the right of the Include Preludes
field to locate the file that you want to include at the beginning of
all pages matching the pattern in the URL pattern field. In this case,
you want the &lt;tt&gt;/template/prelude.jspf&lt;/tt&gt; file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Browse button to the right of the Include Codas field
to locate the file that you want to include at the end of all pages
matching the URL pattern. In this case, you want the &lt;tt&gt;/template/coda.jspf&lt;/tt&gt; file.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Instead of performing the preceding steps, you can add preludes and codas by
editing the XML by hand using NetBeans IDE by doing the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Perform steps 1 through 3 in the preceding set of steps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click XML at the top of the editor pane.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a new JSP property group (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnajg.html"&gt;Setting Properties for Groups of JSP Pages&lt;/a&gt;) and give it the name &lt;tt&gt;bookstore2&lt;/tt&gt; and URL pattern &lt;tt&gt;*.jsp&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add an &lt;tt&gt;include-prelude&lt;/tt&gt; element to the &lt;tt&gt;jsp-property-group&lt;/tt&gt; element and give it the name of the file to include, in this case, &lt;tt&gt;/template/prelude.jspf&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add an &lt;tt&gt;include-coda&lt;/tt&gt; element to the &lt;tt&gt;jsp-property-group&lt;/tt&gt; element and give it the name of the file to include, in this case, &lt;tt&gt;/template/coda.jspf&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Preludes and codas can put the included code only at the beginning
and end of each file. For a more flexible approach to building pages
out of content chunks, see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnann.html#bnaoh"&gt;A Template Tag Library&lt;/a&gt;.&lt;/p&gt;

&lt;a name="bnajm"&gt;&lt;/a&gt;&lt;h5&gt;Eliminating Extra White Space&lt;/h5&gt;
&lt;p&gt;White space included in the template text of JSP pages is preserved by
default. This can have undesirable effects. For example, a carriage return added after
a &lt;tt&gt;taglib&lt;/tt&gt; directive would be added to the response output as an extra
line.&lt;/p&gt;&lt;p&gt;If you want to eliminate the extra white space from the page,
you can add a &lt;tt&gt;trim-directive-whitespaces&lt;/tt&gt; element to a &lt;tt&gt;jsp-property-group&lt;/tt&gt; element in the deployment
descriptor and set it to &lt;tt&gt;true&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;To set the &lt;tt&gt;trim-directive-whitespaces&lt;/tt&gt; element to true using NetBeans 5.5, do the following:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Open the deployment descriptor file in the editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Pages button at the top of the editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select a JSP property group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Trim Directive Whitespaces check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the deployment descriptor.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Alternatively, a page author can set the value of the &lt;tt&gt;trimDirectiveWhitespaces&lt;/tt&gt; attribute
of the &lt;tt&gt;page&lt;/tt&gt; directive to true or false. This will override the value
specified in the deployment descriptor.&lt;/p&gt;&lt;p&gt;Custom tag authors can eliminate white space from the output generated by a
tag file by setting the &lt;tt&gt;trimDirectiveWhiteSpace&lt;/tt&gt; attribute of the &lt;tt&gt;tag&lt;/tt&gt; directive to true.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="22307277085" hide="0">
			<date>January  20, 2008</date>
			<title>Including an Applet</title>
			<description>&lt;p&gt;You can include an applet or a JavaBeans component in a JSP page
by using the &lt;tt&gt;jsp:plugin&lt;/tt&gt; element. This element generates HTML that contains the appropriate
client-browser-dependent construct (&lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; or &lt;tt&gt;&amp;lt;embed&amp;gt;&lt;/tt&gt;) that will result in the download of the Java
Plug-in software (if required) and the client-side component, and in the subsequent execution
of any client-side component. The syntax for the &lt;tt&gt;jsp:plugin&lt;/tt&gt; element is as follows:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:plugin
     type="bean|applet"
     code="&lt;i&gt;objectCode&lt;/i&gt;"
     codebase="&lt;i&gt;objectCodebase&lt;/i&gt;"
     { align="&lt;i&gt;alignment&lt;/i&gt;" }
     { archive="&lt;i&gt;archiveList&lt;/i&gt;" }
     { height="&lt;i&gt;height&lt;/i&gt;" }
     { hspace="&lt;i&gt;hspace&lt;/i&gt;" }
     { jreversion="&lt;i&gt;jreversion&lt;/i&gt;" }
     { name="&lt;i&gt;componentName&lt;/i&gt;" }
     { vspace="&lt;i&gt;vspace&lt;/i&gt;" }
     { width="&lt;i&gt;width&lt;/i&gt;" }
     { nspluginurl="&lt;i&gt;url&lt;/i&gt;" }
     { iepluginurl="&lt;i&gt;url&lt;/i&gt;" } &amp;gt;
     { &amp;lt;jsp:params&amp;gt;
         { &amp;lt;jsp:param name="&lt;i&gt;paramName&lt;/i&gt;" value= &lt;i&gt;paramValue&lt;/i&gt;" /&amp;gt; }+
    &amp;lt;/jsp:params&amp;gt; }
     { &amp;lt;jsp:fallback&amp;gt; &lt;i&gt;arbitrary-text&lt;/i&gt; &amp;lt;/jsp:fallback&amp;gt; }
 &amp;lt;/jsp:plugin&amp;gt;&lt;/pre&gt;&lt;p&gt;The &lt;tt&gt;jsp:plugin&lt;/tt&gt; tag is replaced by either an &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; or an &lt;tt&gt;&amp;lt;embed&amp;gt;&lt;/tt&gt;
tag as appropriate for the requesting client. The attributes of the &lt;tt&gt;jsp:plugin&lt;/tt&gt; tag provide
configuration data for the presentation of the element as well as the version
of the plug-in required. The &lt;tt&gt;nspluginurl&lt;/tt&gt; and &lt;tt&gt;iepluginurl&lt;/tt&gt; attributes override the default
URL where the plug-in can be downloaded.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-409"&gt;&lt;/a&gt;&lt;a name="indexterm-410"&gt;&lt;/a&gt;The &lt;tt&gt;jsp:params&lt;/tt&gt; element specifies parameters to the applet or JavaBeans component. The &lt;tt&gt;jsp:fallback&lt;/tt&gt;
element indicates the content to be used by the client browser if the
plug-in cannot be started (either because &lt;tt&gt;&amp;lt;object&amp;gt;&lt;/tt&gt; or &lt;tt&gt;&amp;lt;embed&amp;gt;&lt;/tt&gt; is not supported by the
client or because of some other problem).&lt;/p&gt;&lt;p&gt;If the plug-in can start but the applet or JavaBeans component cannot be
found or started, a plug-in-specific message will be presented to the user, most
likely a pop-up window reporting a &lt;tt&gt;ClassNotFoundException&lt;/tt&gt;.&lt;/p&gt;&lt;p&gt;&lt;a name="indexterm-411"&gt;&lt;/a&gt;The Duke’s Bookstore page &lt;tt&gt;/template/prelude.jspf&lt;/tt&gt; creates the banner that displays a dynamic digital
clock generated by &lt;tt&gt;DigitalClock&lt;/tt&gt; (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaje.html#bnajf"&gt;Figure 5-3&lt;/a&gt;).&lt;/p&gt;&lt;a name="bnajf"&gt;&lt;/a&gt;&lt;h6&gt;Figure 5-3 Duke’s Bookstore with Applet&lt;/h6&gt;&lt;img src="http://java.sun.com/javaee/5/docs/tutorial/doc/figures/web-applet.gif" alt="Screen capture of Duke&amp;#8216;s Bookstore with " components="" for="" web="" developers="" recommendation,="" start="" shopping="" link="" date="" and="" time="" applet.="" height="568" width="662"&gt;&lt;p&gt;Here is the &lt;tt&gt;jsp:plugin&lt;/tt&gt; element that is used to download the applet:&lt;/p&gt;&lt;pre&gt;&amp;lt;jsp:plugin
     type="applet"
     code="DigitalClock.class"
     codebase="/bookstore2"
     jreversion="1.4"
     align="center" height="25" width="300"
    nspluginurl="http://java.sun.com/j2se/1.4.2/download.html"
     iepluginurl="http://java.sun.com/j2se/1.4.2/download.html" &amp;gt;
    &amp;lt;jsp:params&amp;gt;
        &amp;lt;jsp:param name="language"
            value="${pageContext.request.locale.language}" /&amp;gt;
        &amp;lt;jsp:param name="country"
            value="${pageContext.request.locale.country}" /&amp;gt;
        &amp;lt;jsp:param name="bgcolor" value="FFFFFF" /&amp;gt;
        &amp;lt;jsp:param name="fgcolor" value="CC0066" /&amp;gt;
    &amp;lt;/jsp:params&amp;gt;
    &amp;lt;jsp:fallback&amp;gt;
        &amp;lt;p&amp;gt;Unable to start plugin.&amp;lt;/p&amp;gt;
    &amp;lt;/jsp:fallback&amp;gt;
&amp;lt;/jsp:plugin&amp;gt;&lt;/pre&gt;</description>
		</newsitem>
		<newsitem id="10484882241" hide="0">
			<date>January  20, 2008</date>
			<title>JavaServer Pages Documents</title>
			<description>&lt;p&gt;A &lt;b&gt;JSP document&lt;/b&gt; is a JSP page written in XML syntax as opposed to
the standard syntax described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnagx.html"&gt;Chapter 5, JavaServer Pages Technology&lt;/a&gt;. Because it is written in XML
syntax, a JSP document is also an XML document and therefore gives you
all the benefits offered by the XML standard:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;You can author a JSP document using one of the many
XML-aware tools on the market, enabling you to ensure that your JSP
document is well-formed XML.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can validate the JSP document against a document type definition (DTD).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can nest and scope namespaces within a JSP document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can use a JSP document for data interchange between web applications and as part of a compile-time XML pipeline.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a name="indexterm-420"&gt;&lt;/a&gt;In addition to these benefits, the XML syntax gives the JSP page author
less complexity and more flexibility. For example, a page author can use any
XML document as a JSP document. Also, elements in XML syntax can be
used in JSP pages written in standard syntax, allowing a gradual transition from
JSP pages to JSP documents.&lt;/p&gt;&lt;p&gt;This chapter gives you details on the benefits of JSP documents and uses
a simple example to show you how easy it is to create
a JSP document.&lt;/p&gt;&lt;p&gt;You can also write tag files in XML syntax. This chapter covers
only JSP documents. Writing tag files in XML syntax will be addressed in
a future release of the tutorial.&lt;/p&gt;</description>
		</newsitem>
		<newsitem id="22232770664" hide="0">
			<date>January  20, 2008</date>
			<title>The Example JSP Document</title>
			<description>&lt;p&gt;This chapter uses the Duke’s Bookstore application, version &lt;tt&gt;bookstore5&lt;/tt&gt;, and the &lt;tt&gt;books&lt;/tt&gt; application to
demonstrate how to write JSP pages in XML syntax. The JSP pages
of the &lt;tt&gt;bookstore5&lt;/tt&gt; application use the JSTL XML tags (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnakq.html"&gt;XML Tag Library&lt;/a&gt;) to
manipulate the book data from an XML stream. The &lt;tt&gt;books&lt;/tt&gt; application contains the
JSP document &lt;tt&gt;books.jspx&lt;/tt&gt;, which accesses the book data from the database and converts
it into the XML stream. The &lt;tt&gt;bookstore5&lt;/tt&gt; application accesses this XML stream to
get the book data.&lt;/p&gt;&lt;p&gt;These applications show how easy it is to generate XML data and
stream it between web applications. The &lt;tt&gt;books&lt;/tt&gt; application can be considered the application hosted
by the book warehouse’s server. The &lt;tt&gt;bookstore5&lt;/tt&gt; application can be considered the application hosted
by the book retailer’s server. In this way, the customer of the bookstore
web site sees the list of books currently available, according to the warehouse’s
database.&lt;/p&gt;&lt;p&gt;The source for the Duke’s Bookstore application is located in the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore5/&lt;/tt&gt; directory, which
is created when you unzip the tutorial bundle (see &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/gfiud.html"&gt;Chapter 2, Using the Tutorial Examples&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;To deploy the &lt;tt&gt;books&lt;/tt&gt; application using NetBeans IDE, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Perform all the operations described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaez.html"&gt;Accessing Databases from Web Applications&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In NetBeans IDE, select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;i&gt;tut-install&lt;/i&gt;/javaeetutorial5/examples/web/&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;books&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box and the Open Required Projects check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;books&lt;/tt&gt; project, and select Deploy Project.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy the &lt;tt&gt;books&lt;/tt&gt; application using the Ant utility, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/books/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant build&lt;/b&gt;&lt;/tt&gt;. This target will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/books/build/&lt;/tt&gt; directory, build a WAR file, and copy the WAR file to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/books/dist/&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To deploy the application, type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy and run the &lt;tt&gt;bookstore5&lt;/tt&gt; application using NetBeans IDE, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;Perform all the operations described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaez.html"&gt;Accessing Databases from Web Applications&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In NetBeans IDE, select File&amp;#8594;Open Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Open Project dialog, navigate to:&lt;/p&gt;&lt;pre&gt;&lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/&lt;/tt&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the &lt;tt&gt;bookstore5&lt;/tt&gt; folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Open as Main Project check box and the Open Required Projects check box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Open Project Folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Projects tab, right-click the &lt;tt&gt;bookstore5&lt;/tt&gt; project, and select Deploy Project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the applications, open the bookstore URL &lt;tt&gt;http://localhost:8080/bookstore5/books/bookstore&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To deploy and run the application using Ant, follow these steps:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;p&gt;In a terminal window, go to &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore5/&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type &lt;tt&gt;&lt;b&gt;ant&lt;/b&gt;&lt;/tt&gt;. This command will spawn any necessary compilations, copy files to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore5/build/&lt;/tt&gt; directory, and create a WAR file and copy it to the &lt;tt&gt;&lt;/tt&gt;&lt;i&gt;tut-install&lt;/i&gt;&lt;tt&gt;/javaeetutorial5/examples/web/bookstore5/dist/&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Application Server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perform all the operations described in &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaez.html#bnafb"&gt;Creating a Data Source in the Application Server&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To deploy the example, type &lt;tt&gt;&lt;b&gt;ant deploy&lt;/b&gt;&lt;/tt&gt;. The &lt;tt&gt;deploy&lt;/tt&gt; target outputs a URL for running the application. Ignore this URL, and instead use the one shown in the next step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the applications, open the bookstore URL &lt;tt&gt;http://localhost:8080/bookstore5/books/bookstore&lt;/tt&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To learn how to configure the &lt;tt&gt;bookstore5&lt;/tt&gt; example, refer to the &lt;tt&gt;web.xml&lt;/tt&gt; file,
which includes the following configurations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A &lt;tt&gt;display-name&lt;/tt&gt; element that specifies the name that tools use to identify the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;context-param&lt;/tt&gt; element that identifies the context path to the XML stream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;context-param&lt;/tt&gt; element that specifies the JSTL resource bundle base name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A set of &lt;tt&gt;servlet&lt;/tt&gt; elements that identify the JSP files in the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A set of &lt;tt&gt;servlet-mapping&lt;/tt&gt; elements that identify aliases to the JSP pages identified by the &lt;tt&gt;servlet&lt;/tt&gt; elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nested inside a &lt;tt&gt;jsp-config&lt;/tt&gt; element are two &lt;tt&gt;jsp-property-group&lt;/tt&gt; elements, which define the preludes and coda to be included in each page. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnair.html#bnaiu"&gt;Setting JavaBeans Component Properties&lt;/a&gt; for more information.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To learn how to configure the &lt;tt&gt;books&lt;/tt&gt; example, refer to the &lt;tt&gt;web.xml&lt;/tt&gt; file,
which includes the following configurations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;A &lt;tt&gt;display-name&lt;/tt&gt; element that specifies the name that tools use to identify the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;listener&lt;/tt&gt; element that identifies the &lt;tt&gt;ContextListener&lt;/tt&gt; class used to create and remove the database access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;tt&gt;servlet&lt;/tt&gt; element that identifies the JSP page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nested inside a &lt;tt&gt;jsp-config&lt;/tt&gt; element is a &lt;tt&gt;jsp-property-group&lt;/tt&gt; element, which identifies the JSP page as an XML document. See &lt;a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnakb.html"&gt;Identifying the JSP Document to the Container&lt;/a&gt; for more information.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</description>
		</newsitem>
	</eligbleviewers>
	<eligbleviewers id="eligbl2" newstosee="5" status1="99" status2="100">
	</eligbleviewers>
	<eligbleviewers id="eligbl3" newstosee="5" status1="199" status2="1200"/>
</news>