expression Tag

expression Tag

You looked at two of the tag types available in the JSP specification. In order to use Java values or variables directly in the JSP, you can use the expression tag.

Structure of the expression Tag

The JSP expression tag can be written in either JSP tag format or XML format:

 <%= expression %>  

or

 <jsp:expression>  // your java expression </jsp:expression> 

The Java code within the expression tag is converted into a java.lang.String since the data within the final generated HTML file is text data. JSP expression tags provide great flexibility in mixing HTML tags and values generated by Java code. The expression tag enables dynamic content to be mixed with static content, enabling the separation of the content from the look and feel of the Web application.

In the following example the expression tag has been used along with the HTML code:

 Book Price:<%=myBook1.displayPrice();%>  

or

 Book Price:<jsp:expression>myBook1.displayPrice();</jsp:expression>  

When the page is rendered on the browser, the look and feel in the JSP (that is, the label "Book Price:") will be displayed along with the book price. The book price is the output of evaluating the expression myBook1.displayPrice(), which returns the output of the evaluated expression. This is an example of generating dynamic content using expression tags.



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net