Creating Static Content - The Java EE 5 Tutorial (original) (raw)
2. Using the Tutorial Examples
3. Getting Started with Web Applications
5. JavaServer Pages Technology
Using Objects within JSP Pages
Using Application-Specific Objects
Immediate and Deferred Evaluation Syntax
Deactivating Expression Evaluation
Process of Expression Evaluation
JavaBeans Component Design Conventions
Creating and Using a JavaBeans Component
Setting JavaBeans Component Properties
Retrieving JavaBeans Component Properties
Including the Tag Library Implementation
Transferring Control to Another Web Component
Setting Properties for Groups of JSP Pages
Deactivating EL Expression Evaluation
Further Information about JavaServer Pages Technology
7. JavaServer Pages Standard Tag Library
10. JavaServer Faces Technology
11. Using JavaServer Faces Technology in JSP Pages
12. Developing with JavaServer Faces Technology
13. Creating Custom UI Components
14. Configuring JavaServer Faces Applications
15. Internationalizing and Localizing Web Applications
16. Building Web Services with JAX-WS
17. Binding between XML Schema and Java Classes
19. SOAP with Attachments API for Java
21. Getting Started with Enterprise Beans
23. A Message-Driven Bean Example
24. Introduction to the Java Persistence API
25. Persistence in the Web Tier
26. Persistence in the EJB Tier
27. The Java Persistence Query Language
28. Introduction to Security in the Java EE Platform
29. Securing Java EE Applications
31. The Java Message Service API
32. Java EE Examples Using the JMS API
36. The Coffee Break Application
37. The Duke's Bank Application
Creating Static Content
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 page directive with the contentType attribute set to the content type. The purpose of the contentType 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:
<%@ page contentType="text/vnd.wap.wml"%>
A registry of content type names is kept by the IANA athttp://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).
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices