A JSP expression element contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file.
Because the value of an expression is converted to a String, you can use an expression within a line of text, whether or not it is tagged with HTML, in a JSP file.
The expression element can contain any expression that is valid according to the Java Language Specification but you cannot use a semicolon to end an expression.
Following is the syntax of JSP Expression −
<%= expression %>
You can write the XML equivalent of the above syntax as follows −
<jsp:expression> expression </jsp:expression>
Following example shows a JSP Expression −
<html> <head> <title>A Comment Test</title> </head> <body> <p>Today's date: <%= (new java.util.Date()).toLocaleString()%></p> </body> </html>
The above code will generate the following result −
Today's date: 11-Sep-2010 21:24:25