• Like
  • Save
Jstl & El
Upcoming SlideShare
Loading in...5
×
 

Jstl & El

on

  • 1,254 views

 

Statistics

Views

Total Views
1,254
Views on SlideShare
1,254
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Jstl & El Jstl & El Presentation Transcript

    • JSTL & EL
    • 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.
    • 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
    • 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}
    • 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.
    • 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
    • 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>
    • 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>
    • 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>
    • 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>
    •  
    •