background image

Scripting in JSP Pages

<< Parameters for the URL | The Web Client Folder >>
<< Parameters for the URL | The Web Client Folder >>

Scripting in JSP Pages

Scripting in JSP Pages
JSP scripting elements allow you to use Java programming language statements in your JSP
pages. Scripting elements are typically used to create and access objects, define methods, and
manage the flow of control. Many tasks that require the use of scripts can be eliminated by using
custom tag libraries, in particular the JSP Standard Tag Library. Because one of the goals of JSP
technology is to separate static data from the code needed to dynamically generate content, very
sparing use of JSP scripting is recommended. Nevertheless, there may be some circumstances
that require its use.
There are three ways to create and use objects in scripting elements:
Instance and class variables of the JSP page's servlet class are created in declarations and
accessed in scriptlets and expressions.
Local variables of the JSP page's servlet class are created and used in scriptlets and
expressions.
Attributes of scope objects (see
"Using Scope Objects" on page 105
) are created and used in
scriptlets and expressions.
This chapter briefly describes the syntax and usage of JSP scripting elements.
The Example JSP Pages
This chapter illustrates JSP scripting elements using webclient, a version of the hello1
example introduced in
Chapter 3, "Getting Started with Web Applications"
that accesses a web
service.
To deploy and run the webclient example using NetBeans IDE, follow these steps:
1. Build and deploy the JAX-WS web service MyHelloService described in
"Building,
Packaging, and Deploying the Service" on page 482
.
2. In NetBeans IDE, select File
Open Project.
9
C H A P T E R
9
273