Advanced Java (2160707)

BE | Semester-4   Winter-2018 | 20-11-2018

Q3) (b)

List the JSTL core tags and explain any two with example.

JSTL Core Tags

  1. c:out
  2. c:import
  3. c:set
  4. c:remove
  5. c:catch
  6. c:if
  7. c:choose
  8. c:when
  9. c:otherwise
  10. c:forEach
  11. c:forTokens
  12. c:param
  13. c:redirect
  14. c:url

c:out

  • It display the result of an expression, similar to the way <%=...%> tag work.
    1. <%@ taglib uri= "http://java.sun.com/jsp/jstl/core" prefix="c" %>
    2. <html>
    3. <body>
    4. <c:out value="${'Welcome to JSTL'}" />
    5. </body>
    6. </html>

c:import

  • It is similar to jsp 'include', with an additional feature of including the content of any resource either within server or outside the server.
    1. <%@ taglib uri= "http://java.sun.com/jsp/jstl/core" prefix="c" %>
    2. <html>
    3. <body>
    4. <c:import var="data" url="http://www.darshan.ac.in" />
    5. <c:out value="${data}" />
    6. </body>
    7. </html>