JSP EXPRESSIONS
JSP Syntax: <%= code %>
XML Syntax: <jsp:expression > code </jsp:expression>
XML Syntax: <jsp:expression > code </jsp:expression>
Printing the output of a Java fragment is one of the most common tasks utilized in JSP
pages. For this purpose, we can use the out.println() method. But having several
out.println() method tends to be cumbersome. Realizing this, the authors of the JSP
specification created the Expression element. The Expression element begins with the
pages. For this purpose, we can use the out.println() method. But having several
out.println() method tends to be cumbersome. Realizing this, the authors of the JSP
specification created the Expression element. The Expression element begins with the
standard JSP start tag followed by an equals sign ( <%= ).
Look at example 3.1. In this example, notice that the out.println() method is removed,
and immediately after the opening JSP tag there is an equals symbol.
Look at example 3.1. In this example, notice that the out.println() method is removed,
and immediately after the opening JSP tag there is an equals symbol.
Example 3.1 date.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
<HTML>
<HEAD>
<TITLE>Current Date</TITLE>
</HEAD>
<BODY>
The current date is:
<%= new java.util.Date() %>
</BODY> Expression element
</HTML>
<HTML>
<HEAD>
<TITLE>Current Date</TITLE>
</HEAD>
<BODY>
The current date is:
<%= new java.util.Date() %>
</BODY> Expression element
</HTML>
No comments:
Post a Comment