JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
Writing Action Element in XML Format
This section describes the syntax of writing Action Elements in XML format for a JSP document. Commonly used standard action elements are: useBean, setProperty, getProperty, include, and forward.
Writing Action Elements in XML format for a JSP Document is also easy. See syntax below:
<action_name attribute=value ...>...</action_name>.
However, JSP supports a large number of standard actions for you:
The most commonly used action element is probably the "useBean" action. More tutorials on "useBean" are provided later in the book.
"element" is a very interesting action element. It can be used with "attribute" and "body" actions to build XML elements in the returning response. Here is a simple JSP Document using "element", "attribute" and "body" actions.
<?xml version="1.0"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.3"> <!-- ElementAction.jspx - Copyright (c) 2006 HerongYang.com. All Rights Reserved. --> <jsp:directive.page contentType="text/html"/> <jsp:element name="html"> <jsp:element name="body"> <jsp:body> <jsp:text> Hello world! - Using "element" action </jsp:text> </jsp:body> </jsp:element> </jsp:element> </jsp:root>
If you open this JSP page with a Web browser, you should see:
Hello world! - Using "element" action
If you open the source code of the Web browser output, you should see:
<html><body> Hello world! - Using "element" action </body></html>
See the next tutorial for more tutorial examples on using Action Elements and other types of JSP elements in JSP Document format.
Table of Contents
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
►Syntax of JSP Pages and JSP Documents
Syntactic Elements of a JSP Page
JSP Document - JSP Page in XML Format
JSP Document - JSP Version Error
Writing Scriptlet Element in XML Format
Writing Directive Element in XML Format
►Writing Action Element in XML Format
"include" Directive and Action Elements
Execution Result of CurrentTime.jspx
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Overview of JSTL (JSP Standard Tag Libraries)
Multiple Tags Working Together
Using Tomcat on CentOS Systems
Connecting to SQL Server from Servlet