Previous | Home | Next |
JSTL (JSP Standard Tag Library)
In JSTL is shows a set of tags to simplify the JSP development.
Advantage
- Fast Developement
- Code Reusability
- No need to use scriptlet tag
There are following tags:
Tag Name | Description |
core tags | The 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 tags | The 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 tags | The 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 tags | The 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 tags | The 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" %>
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>
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>
<%@ 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 |