JSP and JSTL Tutorials - Tutorial Addendum - JSTL - Syntax and Announcement Accent
| |
(Continued from antecedent part...)
As you can see, this action is actual complex. But it does create page columnist s
life easier by putting a lot of intelligence abaft this operation. But it also
brings a lot of abashing if you alter the code.
The JSTL blueprint about the "." and "" operators is quoted beneath as
reference. But I accept my description is abundant easier to understand.
The announcement accent follows ECMAScript in accumulation the analysis of
the "." and "" operators.
expr-a.identifier-b is agnate to a; that is, the
identifier identifier-b is acclimated to assemble a accurate whose amount is
the identifier, and then the "" operartor is acclimated with that value.
To appraise expr-a:
. Appraise expr-a into value-a
. if value-a is null, acknowledgment null.
. Appraise expr-b into value-b
. if value-b is null, acknowledgment null.
. if value-a is a Map, Account or array
. if value-a is a Map
. if !value-a.containsKey(value-b) then acknowledgment null.
. otherwise, acknowledgment value-a.get(value-b)
. if value-a is a Account or array
. beset value-b to int (using coercing rules);
. if browbeating couldn t be performed: error
. then, if value-a.get(value-b) or Array.get(value-a, value-b)
throws ArrayIndexOutOfBoundsException or
IndexOutOfBoundsException: acknowledgment null
. otherwise, if value-a.get(value-b) or Array.get(value-a, value-b)
throws additional exception, error
. otherwise, acknowledgment value-a.get(value-b) or Array.get(value-a,
value-b), as appropriate.
. Contrarily (a JavaBeans object), beset value-b to String
. If value-b is a clear acreage of value-a
. if getter throws an exception: error
. otherwise; acknowledgment aftereffect of getter call
. otherwise: error
ExpExample.jsp - Announcement Archetype Page
To analysis my compassionate of the announcement language, I wrote the afterward
JSP to appearance some announcement examples.
<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jstl/core" version="1.2">
<!-- ExpExample.jsp
Absorb (c) 2003 by Dr. Yang
-->
<jsp:directive.page contentType="text/html"/>
<html><body>
<p>JSTL Announcement Examples:</p>
<c:out value="1. ${1+1==2}"/><br/>
<c:out value="2. ${1+1}"/><br/>
<c:out value="3. ${1/3}"/><br/>
<c:out value="4. ${1.0/3.0}"/><br/>
<c:out value="5. ${quantity*price lt 100.0 and country== USA }"/><br/>
<c:set var="message" value="Hi there!"/>
<c:out value="6. ${message}"/><br/>
<c:out value="7. ${ bulletin }"/><br/>
<c:out value="10. ${pageContext.request.method}"/><br/>
<c:out value="11. ${pageContext.request}"/><br/>
<c:out value="12. ${pageContext.request}"/><br/>
<!-- c:out value="13. ${pageContext.request. adjustment }"/><br/ -->
<!-- c:out value="14. ${pageContext. appeal .method}"/><br/ -->
<c:out value="15. ${pageContext}"/><br/>
<c:out value="16. ${pageContext.method}"/><br/>
<!-- c:out value="20. ${pageContext.request.cookies.length}"/><br/ -->
<c:out value="21. ${pageContext.request.cookies.name}"/><br/>
<c:out value="22. ${pageContext.request.cookies.value}"/><br/>
<c:out value="23. ${pageContext.request.cookies}"/><br/>
<!-- c:out value="24. ${pageContext.request.cookies.0}"/><br/ -->
<!-- c:out value="25. ${pageContext.request.cookies.0.name}"/><br/ -->
<c:out value="26. ${pageContext.request.cookies}"/><br/>
<jsp:scriptlet>double pi = 3.14159;</jsp:scriptlet>
<c:out value="30. ${pi}"/><br/>
<jsp:scriptlet>
double account = new double;
list = 9.99;
</jsp:scriptlet>
<c:out value="31. ${list}"/><br/>
<c:out value="32. ${pageContext.request.class.name}"/><br/>
<c:out value="33. ${pageContext]}"/><br/>
<c:out value="34. ${out.class.name}"/><br/>
<c:out value="35. ${pageContext.out.class.name}"/><br/>
<!-- c:out value="36. ${sessionScope.now}"/><br/ -->
<jsp:scriptlet>
session.setAttribute("now", new java.util.Date());
</jsp:scriptlet>
<c:out value="37. ${sessionScope.now.time}"/><br/>
</body></html>
</jsp:root>
Here is the achievement this page. But you apprehend the output, I wish you yield guess
on the consistent ethics my announcement examples would accord and analyze them
with the output.
JSTL Announcement Examples:
1. true
2. 2
3. 0.3333333333333333
4. 0.3333333333333333
5. false
6. Hi there!
7. message
10. GET
11.
12. GET
15. GET
16. GET
21. JSESSIONID
22. FAC70AB7F4107E5EC81A14B1C080FC79
23. javax.servlet.http.Cookie@352d87
26. javax.servlet.http.Cookie@352d87
30.
31.
32. org.apache.coyote.tomcat4.CoyoteRequestFacade
33.
34.
35. org.apache.jasper.runtime.JspWriterImpl
37. 1065795381165
(Continued on next part...)
|
value, {pagecontext, request, expression, cookies, return, scriptlet, identifier, array, name}, class, method, examples, language, output, double, evaluate, throws, error, method}, , {pagecontext request, < jsp, request cookies, jsp scriptlet, name} <, expression examples, expression language, return null, request method, scriptlet <, class name}, request method}, array get, html <, evaluate expr, method} <, {pagecontext request cookies, {pagecontext request method, {pagecontext request method}, jsp scriptlet double, javax servlet http, {pagecontext request class, jstl expression examples, error otherwise return, tutorial notes jstl, tutorials tutorial notes, notes jstl syntax, null return null, exception error otherwise, return null otherwise, jstl tutorials tutorial, |
Also see ...
i(Continued from antecedent part...)/iDo you accept any supprises if you analyze your assumption with output? I accept someexplanations on the achievement to advice you:Example 3 show
This affiliate explains:How characters biking from JSP files to browser screens.How ASCII characters plan in JSP pages. How to present non ASCII characters in HTML d
i(Continued from antecedent part...)/iLet s attending at the additional allotment first to see how non ASCII characters are stored in HTML documents, transferred from Web servers to browsers, displayed on
i(Continued from antecedent part...)/iJava Strings Byte Sequences Encoded for Bounded LanguagesLet s try advantage 1 mentioned in the antecedent area first. Actuality is my
i(Continued from antecedent part...)/iIn adjustment to analysis out how to ascendancy those factors, I best two simplifiedChinese characters, and entered them in 7 altered formats as a simple HTML paragraph:
i(Continued from antecedent part...)/iStatic HTML Argument JSP Page in XML SyntaxIn the third test, the changeless argument is amid into a JSP page in XML syntax:br
Calculating Prime NumbersThe first breadth I wish to analysis for achievement is accumulation addition calculations. The afterward JSP page calculates prime amount starting from amo
i(Continued from antecedent part...)/iResponse Time of "Hello" PageThe next breadth I wish analysis is absolute acknowledgment time of ASP pages. To do this, I wroteth
This affiliate describes:HTTP Acknowledgment SyntaxHTTP Acknowledgment Attack LinesControlling Attack LinesViewing Attack Linesbr
i(Continued from antecedent part...)/i2. Acknowledgment attack lines: Advice about the response: Accept Ranges Age ETag Area