JSP Expression – Syntax and Example
A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client.
When the scripting language is the Java programming language, an expression is transformed into a statement that converts the value of the expression into a String object and inserts it into the implicit out object.
JSP Expression Syntax
1 |
<%= expression %> |
You can write XML equivalent of the above syntax as follows:
1 2 3 |
<jsp:expression> expression </jsp:expression> |
JSP Expression Example
1 2 3 4 5 6 7 8 |
<html> <head><title>A Comment Test</title></head> <body> <p> Today's date: <%= (new java.util.Date()).toLocaleString()%> </p> </body> </html> |