Pages

JSTL

JSTL
JSTL

JSTL stands for JSP Standard Tag Library which is a collection of very useful core tags and functions. These tags and functions will help you write JSP code efficiently. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating the existing custom tags with the JSTL tags.

Types of JSTL Tags
  1. JSTL SQL Tags
  2. JSTL XML Tags
  3. JSTL Core Tags
  4. JSTL Functions Tags
  5. JSTL Formatting Tags
JSTL Core Tags <c:out> : The tag displays the result of an expression.
Example : <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <html> <head> <title> <c:out> Core Tage Example </c:out> </title> </head> <body> <c:out value = "${'Jaladhi Soft Technology (JST)'}"/> </body> </html>
Output : Jaladhi Soft Technology (JST)
<c:import> : The tag is used for importing the content from another file (or) page to the current JSP page.
Example : <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <html> <head> <title><c:import> Core Tag Example </c:import> </title> </head> <body> <c:import var = "data" url = "https://jaladhisofttech.blogspot.com"/> <c:out value = "${data}"/> </body> </html>
Output : Jaladhi Soft Technology (JST)
<c:set> : The tag is used for assigning a value to an object or variable within a specified scope.
Example : <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <html> <head> <title><c:set> Tag Example </c:set> </title> </head> <body> <c:set var = "salary" scope = "session" value = "${3000*2}"/> <c:out value = "${salary}"/> </body> </html>
Output : 6000
<c:remove> : The tag is used for removing an attribute from a specified scope or from all scopes (page, request, session and application).
Example : <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> <html> <head> <title> Core Tag Example</title> </head> <body> <c:set var = "salary" scope = "session" value = "${3000*2}"/> <p>Before Remove Value: <c:out value = "${salary}"/></p> <c:remove var = "salary"/> <p>After Remove Value: <c:out value = "${salary}"/></p> </body> </html> Output :
Before Remove Value: 6000
After Remove Value: