JSTL

Card Set Information

Author:
info2anu
ID:
31217
Filename:
JSTL
Updated:
2010-08-25 17:47:01
Tags:
JSTL
Folders:

Description:
JSTL
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user info2anu on FreezingBlue Flashcards. What would you like to do?


  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  2. <c:out value='${xyz}' escapeXml='true' />
    Any HTML tags are not evaluated. If you set set escapeXml to false, HTML tags are evaluated.
  3. <c:out value='${user}' default='guest' />
    If the EL or expression (value) evaluates to null, default value is printed.
  4. <c:forEach var="movie" items="${movieList}" varStatus="loopCount">
    ${movie}, ${loopCount.count}
    </c:forEach>
    <c:forEach> is used to iterate through collections and arrays. It iterates through items.
  5. <c:if test="{userType eq 'member'}" >
    doSomething
    </c:if>
  6. <c:choose>
    <c:when test
    ="${x > 1}" >doSomething</c:when>
    <c:when test
    ="${x > 2}" >doSomething</c:when>
    <c:otherwise>something else</c:otherwise>
    </c:choose>
    Only one of the whens or otherwise runs. There is no fall through logic like switch statement.
  7. Setting an attribute variable - var with <c:set>
    <c:set var="userName" value="cowboy" scope="session" />
    or
    <c:set var=
    "userName" scope="session" >
    cowboy
    </c:set>
    • 1. If there is no attribute in the specified scope, tag creates one (assuming value is not null)
    • 2. If the value evaluates to null, the variable is REMOVED.
    • 3. Value doesn't have to be String.
    • 4. Scope is optional. Default is page scope.
  8. Setting property or value of a bean or a Map - <c:set> with target
    <c:set target="${petMap}" property="dogName" value="clover" />

    Value can be specified as body
    • 1. The target must evaluate to Object and NOT String. That means we can use a EL expression or scripting expression (<%= %>) or <jsp:attribute>
    • 2. If target expression is null or is not a bean or a Map, the container throws an exception.
    • 3. If target is a bean and the property is not found, exception is thrown. (same with ${bean.notAProperty} ).
  9. <c:remove var="status" scope="request"/>
    • 1. The var must be a String literal. It can't be an expression.
    • 2. Scope is optional. If you leave out the scope, the attribute is removed from ALL scopes
  10. <c:import url="http://akdjask.com" />
    or
    <c:import url=
    "http://akdjask.com" >
    <c:param name=
    "subtitle" value="aksdjkadja" />
    </c:import>
    • 1. Adds the content dynamically
    • 2. Can reach outside the web app
    • 3. ${param.subtitle}
  11. <c:url value="/comments.jsp" />
    Url rewriting
  12. <c:catch var="myException">
    </c:catch>
    • 1. myException is of type Throwable,
    • 2. You can use ${myException.message}
    • 3. Nothing in the catch after exception will be printed.
    • 4. Error Page mechanism will not kick in when using <c:catch>

What would you like to do?

Home > Flashcards > Print Preview