- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a JSP Expression?
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
- How to print a date using JSP Expression?
- How to write a comment in a JSP page?
- How to write a conditional expression in lambda expression in Java?
- How to write a for loop in a JSP page?
- How to write a while loop in a JSP page?
- How to write a switch statement in a JSP page?
- How to print result of a java expression in JSP?
- How to print XPath Expression result in JSP?
- I want to create a custom tag in JSP. How to write a custom tag in JSP?
- How to write a Python regular expression to use re.findall()?
- How to write a Python Regular Expression to validate numbers?
- How to write an if-else statement in a JSP page?
- How to set result of a java expression in a property in JSP?