Your SlideShare is downloading. ×
Jstl & El
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Jstl & El

861
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
861
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JSTL & EL
  • 2. JSTL ( JSP Standard Tag Library)
    • JSTL provides core functionalities common to many JSP applications.
    • Instead of mixing tags from different vendors in our JSP applications, its preferable to use JSTL due to which we can deploy our application on any JSP container that supports JSTL .
    • JSTL provides tags for
        • Handling flow control
        • Tags for accessing database through SQL
        • For Iteration like statements
        • Internalization
        • Manipulating the XML documents.
  • 3. JSTL ( JSP Standard Tag Library)
    • JSTL is composed of 4 tag libraries :-
        • Core
        • SQL
        • XML manipulation
        • Internationalization & Formatting
    • These libraries are defined by TLD files.
    prefix Used for Library x XML Manipulation XML fmt Locale, Message formatting, Number & Date formatting i18N sql Database accessing SQL c Variable support, Flow Control, URL Management etc. Core
  • 4. JSTL Expression Language (EL)
    • One of the most important features of the JSTL & JSP 2.0 specification.
    • Provides a much simpler syntax for application data manipulation.
    • Accessed via ${expression}.
    • Provides shorthand for accessing :
      • Attributes of standard servlet objects.
      • Bean properties
      • Map, List and array elements
      • Ex : ${5>6}
      • ${param.name}
  • 5. Implicit Objects in EL
    • Implicit objects allow for access to any variables that are held in the particular JSP scopes
      • pageScope, requestScope, sessionScope, applicationScope
      • All these xScope objects are Maps that map the respective scope attribute names to their values.
    • param and paramValues allow to access HTTP request parameters.
    • header and headerValues allow access to HTTP request headers.
    • initParam gives access to context initialization parameters.
    • cookie exposes cookies received in the request.
    • pageContext gives access to all properties associated with the PageContext of a JSP page such as HttpServletRequest, ServletContext, and HttpSession objects & their properties.
  • 6. Operators used in EL
    • EL provides operators for comparison and manipulation of data.
    • EL provides operators for comparison and manipulation of data.
    empty Validation = = (eq), !=(ne), <(lt), >(gt),<=(le), >=(ge) Relational && (and), || (or), ! (not) Logical +, -, *, / (div), % (mod) Arithmetic Operators Category
  • 7. Iteration Tags
    • Looping with explicit numeric values.
        • <c:forEach var=&quot;v&quot; begin=&quot;10&quot; end=&quot;20&quot;>
        • <c:out value=&quot;${v}&quot;/><BR>
        • </c:forEach>
    • Looping with a designated step size
        • <% session.setAttribute(&quot;last&quot;,100); %>
        • <c:forEach var=&quot;v&quot; begin=&quot;10&quot; end=&quot;${sessionScope.last}&quot; step=&quot;2&quot;>
        • <c:out value=&quot;${v}&quot;/><BR>
        • </c:forEach>
    • Looping down an array
        • <c:forEach var=&quot;v&quot; items=&quot;${paramValues.items}&quot;>
        • <c:out value=&quot;${v}&quot;/><BR>
        • </c:forEach>
    • Looping down comma delimited string
        • <c:forEach var=&quot;v&quot; items=&quot;US,INDIA,England&quot;>
        • <c:out value=&quot;${v}&quot;/><BR>
        • </c:forEach>
  • 8. Iteration Tags contd.
    • Looping down arbitrarily delimited Strings
        • <c:forTokens var=&quot;v&quot; items=&quot;(orange(mango)(pineapple)(papaya))&quot; delims=&quot;()&quot;>
        • <c:out value=&quot;${v}&quot;/><BR>
        • </c:forTokens>
  • 9. Conditional Evalutation Tags
    • One choice : if
        • <c:if test=&quot;${12>6}&quot;>
        • <c:out value=&quot;12 is greater than 6&quot;/>
        • </c:if>
    • Lots of Choices : choose
        • <c:choose>
        • <c:when test=&quot;${param.name == &quot;x&quot;}&quot;> X </c:when>
        • <c:when test=&quot;${param.name eq &quot;y&quot;}&quot;>Y</c:when>
        • <c:otherwise>No Parameter value for name</c:otherwise>
        • </c:choose>
  • 10. Database Access Tags
    • <sql:setDataSource driver=&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot; url=&quot;jdbc:odbc:myDsn&quot; user=&quot;&quot; password=&quot;&quot;/>
    • <sql:query var=&quot;result&quot; sql=&quot;select * from Table1&quot; />
    • <c:forEach var=&quot;row&quot; items=&quot;${result.rows}&quot;>
    • <c:out value=&quot;${row.name}&quot;/>
    • <c:out value=&quot;${row.roll}&quot;/><BR>
    • </c:forEach>
  • 11.  
  • 12.  

×