When all scriptlet fragments in a given translation unit are combined in the order they appear
in the JSP page, they shall yield a valid statement or sequence thereof, in the specified
scripting language.
If you want to use the
%>
character sequence as literal characters in a scriptlet, rather than to
end the scriptlet, you can escape them by typing
%\>
.
Examples
Here is a simple example where the page changed dynamically depending on the time of day.
<% if (Calendar.getInstance().get(Calendar.AM_PM) == Calendar.AM) {%>
Good Morning
<% } else { %>
Good Afternoon
<% } %>
Syntax
<%
scriptlet
%>
2.10.3
Expressions
An expression element in a JSP page is a scripting language expression that is evaluated and
the result is coerced to a
String
which is subsequently emitted into the current
out
JspWriter
object.
If the result of the expression cannot be coerced to a
String
then either a translation time
error shall occur, or, if the coercion cannot be detected during translation, a
ClassCastException
shall be raised at request time.
A scripting language may support side effects in expressions. If so, they take effect when the
expression is evaluated. Expressions are evaluated left to right in the JSP page. If the
expressions appear in more than one run time attribute, they are evaluated left to right in the
tag. An expression might change the value of the
out
object, although this is not something
to be done lightly.
The contents of an expression must be a complete expression in the scripting language in
which they are written.
Expressions are evaluated at HTTP processing time. The value of an expression is converted
to a String and inserted at the proper position in the .
jsp
file.
Chapter 2
Standard Syntax and Semantics
56
JSP Web Hosting JavaServer Pages Specifications JSP Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |