Jsp Tutorial Home

Jsp Home

JSP Resources

Community

Site

Core taglib is the important taglib in the JSTL. It includes the core concepts of the programming like declaring the variable, decision making tags etc.. The next sections will explain all the core taglib tags, which are generally used in the programming.


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


Variable Support Tags


The <c:set> tag sets the value of an EL variable or the property in any of the JSP scopes (page, request, session, or application). If the variable does not exists, it will be created.


The JSP EL variable or property can be set either from the attribute value:


<c:set var="var" scope="session" value="..."/>


OR


<c:set var="var">
...
</c:set>


To remove an EL variable, you use the <c:remove> tag as follows:


<c:remove var="test" scope="session"/>


Conditional Tags
The <c:if> tag allows the conditional execution of its body according to the value of the test attribute. The syntax of the <c:if> conditional block is as follows:-


<c:if test="${condition}"> </c:if>



The <c:choose> tag performs conditional block execution by the embedded <c:when> tags. It renders the body of the first <c:when> tag whose test condition evaluates to be true. If none of the test conditions evaluates to be true, then the body of <c:otherwise> tag is evaluated, if present. The syntax is as follows :-


<c:choose>
     <c:when
test="condition1" >
     ...
     </c:when>
    <c:when
test="condition2" >
    ...
    </c:when>
    <c:otherwise>
    </c:otherwise>
</c:choose>
                    

Copyright © 2014 VisualBuilder. All rights reserved