JSP Tutorials

JSTL in JSP
Previous Home Next
adplus-dvertising

JSTL (JSP Standard Tag Library)

In JSTL is shows a set of tags to simplify the JSP development.

Advantage

  1. Fast Developement
  2. Code Reusability
  3. No need to use scriptlet tag

There are following tags:

Tag NameDescription
core tagsThe JSTL core tag provide variable support, URL management, flow control etc. The url for the core tag is http://java.sun.com/jsp/jstl/core . The prefix of core tag is c.
sql tagsThe JSTL sql tags provide SQL support. The url for the sql tags is http://java.sun.com/jsp/jstl/sql and prefix is sql.
xml tagsThe xml sql tags provide flow control, transformation etc. The url for the xml tags is http://java.sun.com/jsp/jstl/xml and prefix is x.
internationalization tagsThe internationalization tags provide support for message formatting, number and date formatting etc. The url for the internationalization tags is http://java.sun.com/jsp/jstl/fmt and prefix is fmt.
functions tagsThe functions tags provide support for string manipulation and string length. The url for the functions tags is http://java.sun.com/jsp/jstl/functions and prefix is fn.

Syntax used

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

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

Its a global exception handling of JSP and handles the exception.

Example of c:catch

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
    <c:catch>  
    int a=10/0;  
    </c:catch>  

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <c:catch>  
    int a=10/0;  
    </c:catch>  
c:out

This tag as a JSP expression tag.

Example of c:out

index.jsp
    <form action="process.jsp" method="post">  
    FirstName:<input type="text" name="fname"/><br/>  
    LastName:<input type="text" name="lname"/><br/>  
    <input type="submit" value="submit"/>  
    </form>  

    <form action="process.jsp" method="post">  
    FirstName:<input type="text" name="fname"/><br/>  
    LastName:<input type="text" name="lname"/><br/>  
    <input type="submit" value="submit"/>  
    </form>  
process.jsp
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" 
prefix="c" %> First Name:<c:out value="${param.fname}"></c:out><br/>  
    Last Name:<c:out value="${param.lname}"></c:out>  

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" 
prefix="c" %> First Name:<c:out value="${param.fname}"></c:out><br/>  
    Last Name:<c:out value="${param.lname}"></c:out>  
Previous Home Next