Monday 22 June 2015

OCEJWCD.- 8.Developing JSP pages using custom tags (part1)

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification
8.1.Relate the JSTL to common job roles in web application development and understand the use of tags in JSP developments.

The Java Standard Tag Library is a collection of standard custom tags
JSTL have a set of libraries:
- Core library
- Formatting library
- XML library
- SQL library

8.2.Recognize correct syntax for tags.

  • To escape XML or set to default and attribute
<c:out value="${message} escapeXml="true"/>
<c:out value="${user} default ="usuario1" />
  • Looping
<c:forEach var="item" items="${itemList}">
  ${item}
</c:out>
  • Conditions
<c:if test=${number eq 5}>
  Condition 1 displayed
</c:if>
  • Nested conditions
<c:choose>
  <c:when test....
  </c:when>
  <c:otherwise>
  </c:otherwise>
</c:choose>
  • set variable in a scope or a bean/map attribute:
<c:set var="name" scope="session" value="user1"/> 
*by default page scope
<c:set target="${beanPerson}" property="name" value="user1"/>
*if the bean is null throws an exception


  • include content dynamically that can be external to the container
<c:import url="....>
  • url rewriting and encoding
<c:url value="input.jsp" var="inputURL">
  <c:param name="name" value="${name}"/>
</c:url>
8.3.Configure a JSP to use tags from the JSTL.

At application level the files: jstl.jar and standard.jar should be in WEB-INF/lib directory.

In the JSP the following declaration should exist to use JSTL: taglib directive

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>

See an example in post ocejwcd-6-more-view-facilities in section  6.5

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification

No comments:

Post a Comment