background image

Creating Dynamic Content

<< Creating Static Content | Unified Expression Language >>
<< Creating Static Content | Unified Expression Language >>

Creating Dynamic Content

<%@ page contentType=
"text/vnd.wap.wml"%>
A registry of content type names is kept by the IANA at
http://www.iana.org/assignments/media-types/
.
Response and Page Encoding
You also use the contentType 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 page directive:
<%@ page contentType=
"text/html; charset=UTF-8" %>
If the response encoding weren't set, the localized dates would not be rendered correctly.
To set the source encoding of the page itself, you would use the following page directive:
<%@ page pageEncoding=
"UTF-8" %>
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
"Declaring Page Encodings" on page 181
).
Creating Dynamic Content
You create dynamic content by accessing Java programming language object properties.
Using Objects within JSP Pages
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.
Using Implicit Objects
Implicit objects 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
Chapter 4, "Java Servlet
Technology."
The section
"Implicit Objects" on page 162
explains how you access implicit
objects using the JSP expression language.
Creating Dynamic Content
Chapter 5 · JavaServer Pages Technology
145