JSP - Expression Tag
JSP Expression
Expression Tag ये expression को print करने के लिए इस्तेमाल किया जाता है | out.print() method पर जो arguments दिए जाते है वही arguument Expression tag में दिए जाते है | जब expression tag इस्तेमाल किया जाता है तब out.print() method की जरुरत नहीं पड़ती है |
Expression Tag को variable, method और class को print करने के लिए इस्तेमाल किया जाता है |
Syntax for Expression Tag
<%= expression %>OR
<jsp:expression> expression not support HTML Tags </jsp:expression>
Note : Expression Tag में expression के end पर semi-colon(;) नहीं दिया जाता है |
Example for Expression Tag
Source Code :Output :<html> <head> <title>Expression Tag - Print Variable</title> </head> <body> <%! int a = 1, b = 2; %> <%= "Value of a : " + a + "<br />" + "Value of b : " + b %> <jsp:expression> "Value of a : " + a + "Value of b : " + b </jsp:expression> </body> </html>
Value of a : 1 Value of b : 2 Value of a : 1Value of b : 2