SCRIPTING ELEMENTS
Now, after going through the basic concepts of JSP, we will understand different types
of tags or scripting elements used in JSP.
of tags or scripting elements used in JSP.
A JSP page contains HTML (or other text-based format such as XML) mixed with
elements of the JSP syntax.
elements of the JSP syntax.
There are five basic types of elements, as well as a special format for comments.
These are:
These are:
1. Scriptlets :The Scriptlet element allows Java code to be embedded directly into
a JSP page.
a JSP page.
2. Expressions:An expression element is a Java language expression whose value
is evaluated and returned as a string to the page.
is evaluated and returned as a string to the page.
3. Declarations: A declaration element is used to declare methods and variables
that are initialized with the page.
that are initialized with the page.
4. Actions: Action elements provide information for the translation phase of the
JSP page, and consist of a set of standard, built-in methods. Custom actions can
also be created in the form of custom tags. This is a new feature of the JSP 1.1
specification.
JSP page, and consist of a set of standard, built-in methods. Custom actions can
also be created in the form of custom tags. This is a new feature of the JSP 1.1
specification.
5. Directives: Directive elements contain global information that is applicable to
the whole page.
the whole page.
The first three elements—Scriptlets, Expressions, and Declarations—are collectively
called scripting elements.
called scripting elements.
There are two different formats in which these elements can be used in a JSP page
• JSP Syntax
The first type of format is called the JSP syntax. It is based on the syntax of other
Server Pages, so it might seem very familiar. It is symbolized by: <% script %>. The
JSP specification refers to this format as the “friendly” syntax, as it is meant for handauthoring.
JSP Syntax: <% code %>
The first type of format is called the JSP syntax. It is based on the syntax of other
Server Pages, so it might seem very familiar. It is symbolized by: <% script %>. The
JSP specification refers to this format as the “friendly” syntax, as it is meant for handauthoring.
JSP Syntax: <% code %>
• XML Standard Format
The second format is an XML standard format for creating JSP pages. This format is
symbolized by: <jsp:element />.
XML syntax would produce the same results, but JSP syntax is recommended for
authoring.
59
XML Syntax: <jsp:scriptlet > code </jsp:scriptlet>
Now, we will discuss about these scripting elements in detail
The second format is an XML standard format for creating JSP pages. This format is
symbolized by: <jsp:element />.
XML syntax would produce the same results, but JSP syntax is recommended for
authoring.
59
XML Syntax: <jsp:scriptlet > code </jsp:scriptlet>
Now, we will discuss about these scripting elements in detail
No comments:
Post a Comment