• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » JSP » JSTL

JSTL fn:trim() Function

By Dinesh Thakur

                  This Function removes the white Space from both side right and left side.

This Function as mentioned above that the removes white space from both side. This program is a demo of this function.  First we call the syntax library for JSTL Accessing. Then after in body section we declare the variable that contain the stored value and then after declare the function syntax that present the output while execution on the web browser. And in the last we close all the html tags.

fn:trim.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

<head>

       <title>&lt;fn:trim&gt; In JSTL</title>

</head>

  <body>

       <center><h3>Example of Trim Function in JSTL</h3></center>

       <b><center><br /><c:out value=”${fn:trim(‘ JSP ‘)}”></c:out>

  </body>

</html>

        JSTL fn:trim() Function

JSTL fn:indexOf() Function

By Dinesh Thakur

           This Function Returns the index within a string of the first occurrence of a substring.

    This function returns the index of a specified substring from the string. In this program we firstly   call the syntax library of JSTL functions for accessing them. After in the body section we declare attributes and the ‘var’ variables that will contain the storing value in it. The main occurrence will be to declaring the string function as we declare. After that close all the html tags. The function we call will present the output on the web browser.

fn:indexOf.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> 

<html> 

<head> 

        <title>&lt;fn:indexOf&gt; In JSTL</title> 

</head> 

    <body> 

         <c:set var=”str1″ value=”Welcome To World Of Java Server Pages.”/> 

         <c:set var=”str2″ value=”Welcome to Java and JSTL Functions”/> 

         <b><center><p>The Output as Index (1) : ${fn:indexOf(str1, “Java”)}</p> 

         <b><center><p>The Output as Index (2) : ${fn:indexOf(str2, “Functions”)}</p> 

    </body> 

  </html>

          JSTL fn:indexOf() Function

JSTL fn:endsWith() Function

By Dinesh Thakur

This Function tests the Input String starts with the given suffix or not.

This Program is a demo of Function <fn:startsWith> in JSTL. This function use to test that the input string starts from the given suffix or not. As per condition then we declare the syntax library of JSTL that will allow to access the JSTL functioning. Then after we declare variable and the syntax of function that will be execute and present the output on the web browser. In the end we close all the html tags.

fn:endsWith.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> 

<html> 

<head> 

       <title>&lt;fn:endsWith&gt; In JSTL</title> 

</head> 

    <body> 

         <c:set var=”str” value=”Welcome to the World of JSP”/> 

         <c:if test=”${fn:endsWith(str, ‘JSP’)}”> 

               <b><center><br /><p>String Ends with JSP<p> 

         </c:if> 

   </body> 

</html>

       JSTL fn:endsWith() Function

JSTL fn:toLowerCase() Function

By Dinesh Thakur

This function uses to converts the string in lower case from upper case.

    This function will convert all the string into lower case from uppercase. First in the program we declare syntax of library function. After that we declare the variables that contain the value that is been given in it. After declaring the function as required we close all the custom tags of Html In the last instance.

fn:toLowerCase.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

<head>

       <title>&lt;fn:toLowerCase&gt; IN JSTL</title>

</head>

   <body>

       <center><h3>Example of Lower Case Function In JSTL</h3></center>

      <c:set var=”str1″ value=”Welcome To Java Server Pages World.”/>

      <c:set var=”str2″ value=”${fn:toLowerCase(str1)}” />

      <p><b><center><p>String After Lower Casing -: ${str2}</p>

   </body>

</html>

        JSTL fn:toLowerCase() Function

JSTL fn:containsIgnoreCase() Function

By Dinesh Thakur

This functions test the case insensitive way substring contained into string or not.

   This function filtrates the condition of insensitive case string from substring. This program is a demo to present the working of this function. First we call the syntax of library that allows user to access the JSTL libraries. Then after in body section we declare attributes and required variable that contain the value that is been use to produce the output on the web browser.

fn:containsIgnoreCase.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

<head>

      <title>&lt;fn:containsIgnoreCase()&gt;In JSTL</title>

</head>

   <body>

     <c:set var=”str1″ value=”Welcome to JSP World”/>

     <c:set var=”str2″ value=”jsp” />

     <c:if test=”${fn:containsIgnoreCase(str1, str2)}”>

          <b><center><p><br/> <c:out value=”String Case Test : str1 contains str2″/>

     </c:if>

   </body>

</html>

       JSTL fn:containsIgnoreCase() Function

JSTL fn:join() Function

By Dinesh Thakur

This Function use to join all the array elements into String.

This function <fn:join> will join the array elements into a string. First we call the syntax library for accessing the JSTL. Then we declare the variables for storing the value that contained by variable. After in the body section we declare the function syntax that will use to execute while compiling and will present the output on the web browser.

fn:Join.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

   <head>

              <title>&lt;fn:Join&gt;In JSTL</title>

   </head>

   <body>

          <c:set var=”str1″ value=”Java Server pages.”/>

          <c:set var=”str2″ value=”${fn:split(str1, ‘ ‘)}” />

          <c:set var=”str3″ value=”${fn:join(str2, ‘-‘)}” />

          <br /><b><center><p>Real String : ${str3}</p>

   </body>

</html> 

        JSTL fn:join() Function

JSTL fn:startsWith() Function

By Dinesh Thakur

               This Function tests the Input String starts with the given prefix or not.

This Program is a demo of Function <fn:startsWith> in JSTL. This function use to test that the input string starts from the given prefix or not. As per condition then we declare the syntax library of JSTL that will allow to access the JSTL functioning. Then after we declare variable and the syntax of function that will be execute and present the output on the web browser. In the end we close all the html tags

  fn:startsWith.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> 

<html> 

<head> 

       <title>&lt;fn:startsWith&gt; In JSTL</title> 

</head> 

    <body> 

        <c:set var=”str” value=”Java Server Pages known as JSP “/> 

        <c:if test=”${fn:startsWith(str, ‘Java’)}”> 

              <b><center><br /><p>String Starts with Java<p> 

       </c:if> 

    </body> 

</html>

       JSTL fn:startsWith() Function

JSTL fn:replace() Function

By Dinesh Thakur

                This Function use to replace the given string in occurrence from the existing String.

In this Program the function <fn:replace> will replace the existing string with given string in condition of function syntax. We declare the library syntax of JSTL. Then after in Body section we declare two variables that will contain the stored value. Both variable contain the string value in next step we use replace function syntax. After declaring the function as required we close all the custom tags of Html In the last instance.

fn:replace.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

   <head>

      <title>&lt;fn:replace&gt; In JSTL</title>

   </head>

    <body>

       <c:set var=”str1″ value=”This Is The Example Of JSP.”/>

       <c:set var=”str2″ value=”${fn:replace(str1,’JSP’, ‘JSTL’)}” />

       <br /><b><center><p>Real String : ${str2}</p>

    </body>

</html>

        JSTL fn:replace() Function

JSTL fn:toUpperCase() Function

By Dinesh Thakur

                                This Function converts all the string into Upper case.

This Program is demo of <fn:UpperCase> in JSTL. This function will convert all the string into Uppercase. First in the program we declare syntax of library function. After that we declare the variables that contain the value that is been given in it. After declaring the function as required we close all the custom tags of Html In the last instance.

fn:uppercase.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

   <head>

          <title>&lt;fn:toUpperCase&gt; IN JSTL</title>

   </head>

   <body>

       <center><h3>Example of Upper Case Function In JSTL</h3></center>

       <c:set var=”str1″ value=”welcome to java server pages world.”/>

       <c:set var=”str2″ value=”${fn:toUpperCase(str1)}” />

       <p><b><center><p>String After Upper Casing -: ${str2}</p>

   </body>

</html>

       JSTL fn:toUpperCase() Function

JSTL fn:split() Function

By Dinesh Thakur

This function use to split a string into subset of an array.

  

This Function use to make splitting of string into array substring. This program shows the demo of this function. First we call the syntax library for JSTL Accessing. Then after in body section we declare the variable that contain the stored value and then after declare the function syntax that present the output while execution on the web browser. And in the last we close all the html tags.

fn:split.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn”%>

  <html>

  <head>

      <title>&lt;fn:split&gt;In JSTL</title>

  </head>

      <body>

         <center><h3>Example Of JSTL Split Function </h3></center>

         <c:set var=”str” value=”This-is-JSP-World” />

         <c:set var=”splitstr” value=”${fn:split(str,’-‘)}” />

         <c:set var=”joinedstr” value=”${fn:join(splitstr,’ ‘)}” />

         <b><center><p>String Before split: ${str}</p>

         <b><center><p>String After split and join: ${joinedstr}</p>

      </body>

 </html>

        JSTL fn:split() Function

JSTL fn:substringAfter() Function

By Dinesh Thakur

                           This Function return the sub set that is following the String.

  This Program is a demo of <fn:substringAfter> In jstl this function will use to return the sub set of string that is been followed on a specific string. As per condition then we declare the syntax library of JSTL that will allow to access the JSTL functioning. Then after we declare variable and the syntax of function that will be execute and present the output on the web browser. In the end we close all the html tags

fn:substringAfter.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

  <head>

      <title>&lt;fn:substringAfter&gt; IN JSTL</title>

  </head>

   <body>

         <center><h3>Example of Substring After In JSTL</h3></center>

         <c:set var=”str1″ value=”Welcome to Java server pages.”/>

         <c:set var=”str2″ value=”${fn:substringAfter(str1,’to’)}” />

         <p><b><center><p>Real Sub String -: ${str2}</p>

   </body>

</html>

       JSTL fn:substringAfter() Function

JSTL fn:escapeXml() Function

By Dinesh Thakur

This Function use to escape the characters that interpreted as XML markup Language.

In this Program first we declare the syntax of function library. After then we declare the variable as per condition the other hand the function used in this program will escape the characters that interprets under xml. After declaring the variables we put the function syntax that will use to execute on the web browser. At last we close all the custom or html tags.

fn:escapeXML.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> 

<html>

    <head>

           <title>&lt;fn:escapeXML&gt; In JSTL</title>

    </head>

   <body>

         <c:set var=”str” value=”This is Example of <b>Java Server Pages</b> escapeXML Function In  JSTL.”></c:set>

         <center><p><br />Without escapeXml function : ${str}

         <br/>

         <center><p><br />With escapeXml function : ${fn:escapeXml(str)}

   </body>

</html>

       JSTL fn:escapeXml() Function

JSTL fn:substring() Function

By Dinesh Thakur

This Function returns the subset of Substring.

This program is a demo that how to execute the <fn:substring> in JSTL. First instance we call the syntax library for accessing the JSTL properly. This Function will return the subset value of a string. Here we declare variable for containing the value in as per condition then after we declare the syntax of function that will represent the output on a web browser so on at the end we close all the custom tags

fn:substring.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> 

<html>

 <head>

         <title>&lt;fn:substring&gt; In JSTL</title>

 </head>

  <body>

         <center><h3>Example of Substring In JSTL</h3></center>

         <br /><b><center><c:out value=”${fn:substring(‘Java Server Pages’,7,10)}”></c:out>

  </body>

</html>  

       JSTL fn:substring() Function

JSTL fn:contains() Function

By Dinesh Thakur

This Function Checks that the Placed String Contains the Sub string or Not.

This Program will show the execution of <fn: contains> function that will bring the output in True or False mode if it will find the substring in string will output ‘TRUE’ otherwise ‘FALSE’. First in the program we declare syntax of library function. After that we declare the variables that contain the value that is been given in it. After declaring the function as required we close all the custom tags of Html In the last instance.

fn:Contains.jsp

<%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c” %>
<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>
<html>
<head>
<title>&lt;fn:Contains&gt; In JSTL</title>
</head>
<body>
<center><br /><strong><p><c:out value=”${fn:contains(‘JavaServerPages’, ‘ver’)}”></c:out>
</body>
</html>

                    JSTL fn:contains() Function

JSTL fn:substringBefore() Function

By Dinesh Thakur

                      This Function use to check the Substring before value of a String. 

 This Program will show how to execute the <fn:substringbefore> in JSTL. As we declare syntax of library function. Then we declare the variables that will contain the stored value and implements the function as required. And a print tag that will print the output on the web browser. All the tags had also been closed as per mandate.

fn:substringBefore.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

<head>

      <title>&lt;fn:substringBefore&gt; IN JSTL</title>

</head>

  <body>

         <center><h3>Example of Substring Before In JSTL</h3></center>

         <c:set var=”str1″ value=”Welcome to Java server pages World.”/>

         <c:set var=”str2″ value=”${fn:substringBefore(str1,’World’)}” />

         <p><b><center><p>Real Sub String -: ${str2}</p>

  </body>

</html>  

        

JSTL fn:length() Function

By Dinesh Thakur

              This Function Use to Count the Length of String or number of Characters in a String.

In This program we just execute the implementation of <fn:length> as we declare the library syntax of JSTL. Then after in Body section we declare two variables that will contain the stored value. Both variable contain the string value in next step we use length function in the output on web browser it will precise the value of character as length of String.

fn:Length.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %>

<html>

<head>

       <title>&lt;fn:Length&gt; In JSTL</title>

</head>

 <body>

      <c:set var=”str1″ value=”Welcome To The World Of Java Server Pages.”/>

      <c:set var=”str2″ value=”This is Example of JSTL Function.” />

      <br /><center><b><p>Length of First String : ${fn:length(str1)}</p>

      <b><center><p>Length of Second String : ${fn:length(str2)}</p>

 </body>

</html>

        JSTL fn:length() Function

JSTL SQL sql:query Tag

By Dinesh Thakur

This tag used to execute the Select Statement in JSTL and stored value in variable.

This tag <sql:Query> used to implement or execute the select statement of sql Query. First we made a database named ‘dbase’ and table with required fields named ‘worker’ that will use to execute or linked with the front end. And all the drivers and attributes are also declared that will create a bridge between database and the coding as res. The query will fetch complete table in the program that will be presented on the web browser.

sqlQuery.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/sql” prefix=”sql”%>

<html>

<head>

     <title>&lt;sql:query&gt;Jstl Tag</title>

</head>

  <body>

     <sql:setDataSource var=”db” driver=”com.mysql.jdbc.Driver”

     url=”jdbc:mysql://localhost/dbase” user=”root” password=”root”/>

       <sql:query var=”dt” dataSource=”${db}”>

          select * from worker

       </sql:query>

        <table border=”1″>

        <tr>

            <td><b>Name</b></td>

            <td><b>Job</b></td>

            <td><b>Age</b></td>

            <td><b>Salary</b></td>

        </tr>

              <c:forEach var=”values” items=”${dt.rows}”>

        <tr>

            <td>${values.name}</td>

            <td>${values.job}</td>

            <td>${values.age}</td>

            <td>${values.salary}</td>

        </tr>

              </c:forEach>

  </table>

  </body>

  </html> 

        JSTL SQL <sql:query> Tag

JSTL SQL sql:param Tag

By Dinesh Thakur

This tag <sql:dateParam> use to assign a value or supply a on required place.  

   

This tag just use to assign value on right place holder in the database this tag used with the reference of <sql:query> and <sql:update>. Like first we made a database named ‘dbase’ with the table named ‘worker’. All the required drivers and attributes are called that can help to access the database with ease. That we use some variable that will be updated with the set value in table as condition matched. In the last we close all the required tags.

 SqlParam.jsp

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

      <%@ taglib uri=”http://java.sun.com/jsp/jstl/sql” prefix=”sql”%>

      <html>

     <head>

          <title>&lt;sql:param&gt;JSTL Tag</title>

     </head>

     <body>

       <sql:setDataSource var=”db” driver=”com.mysql.jdbc.Driver”

       url=”jdbc:mysql://localhost/dbase” user=”root” password=”root”/>

       <c:set var=”age” value=”30″/>

          <sql:update dataSource=”${db}” var=”updt”>

               UPDATE worker SET name=”Sid” WHERE age=?

              <sql:param value=”${age}”/>

          </sql:update>

            <sql:query var=”dt” dataSource=”${db}”>

                select * from worker

            </sql:query>

            <table border=”1″>

            <tr>

                <td><b>Name</b></td>

                <td><b>Job</b></td>

                <td><b>Age</b></td>

                <td><b>Salary</b></td>

            </tr>

              <c:forEach var=”values” items=”${dt.rows}”>

            <tr>

                <td>${values.name}</td>

                <td>${values.job}</td>

                <td>${values.age}</td>

                <td>${values.salary}</td>

            </tr>

              </c:forEach>

  </table>

  </body>

</html>

      JSTL SQL <sql:param> Tag

JSTL SQL sql:dateParam Tag

By Dinesh Thakur

This tag <sql:dateParam> use to assign a value or supply a date and time on required place within the reference of <sql:query> and <sql:update>. 

 

In this Program we mention <sql:dateParam> tag that will be execute with the use <sql:query> and <sql:update>.This tag is will implemented the value on required place holder as date or time in database. For access on database we declare drivers or the attributes that are must for database calling. Here we made a database named ‘dbirth’ with a table named ‘d_birth’ . That has to store the updating values and other query like to insert value. At last all the tags have to be closed the output on web browser will be come in the tabular mode.

Sql:dateParam.jsp

 <%@ page import=”java.util.Date,java.text.*” %>

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/sql” prefix=”sql”%>

<html>

<head>

<title>&lt;sql:dateParam&gt;In JSTL </title>

</head>

  <body>

      <sql:setDataSource var=”db” driver=”com.mysql.jdbc.Driver”

      url=”jdbc:mysql://localhost/dbirth” user=”root” password=”root”/>

      <%  Date DoB = new Date(“1989/02/16”);

        int sal = 18000;

      %>

       <sql:update dataSource=”${db}” var=”updt”>

            UPDATE d_birth SET dob = ? WHERE salary = ?

             <sql:dateParam value=”<%=DoB%>” type=”DATE” />

             <sql:param value=”<%=sal%>” />

       </sql:update>

       <sql:query var=”dt” dataSource=”${db}”>

           select * from d_birth

       </sql:query>

       <table border=”1″>

       <tr>

           <td><b>Name</b></td>

           <td><b>Last Name</b></td>

           <td><b>Salary</b></td>

           <td><b>D.O.B</b></td>

       </tr>

            <c:forEach var=”values” items=”${dt.rows}”>

       <tr>

           <td>${values.name}</td>

           <td>${values.l_name}</td>

           <td>${values.salary}</td>

           <td>${values.dob}</td>

       </tr>

          </c:forEach>

   </table>

  </body>

</html>                                                              JSTL SQL <sql:dateParam> Tag

JSTL SQL sql:update Tag

By Dinesh Thakur

This Tag <sql:update> Execute The Sql statement like Insert,Update or Delete.

In This Program We Execute the Update Query to inserting a value in Connected Database. First we made a database named ‘dbase’ and Table with required fields named ‘worker’. Then after declaring the required variable we call The Drivers and Other attributes that are must for accessing the procedure to execute program and sql query. Here in last we produce the output on web browser in tabular form.

 Sql:Update.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/sql” prefix=”sql”%>

<html>

<head>

      <title>&lt;sql:update&gt;Jstl Tag</title>

</head>

  <body>

             <sql:setDataSource var=”db” driver=”com.mysql.jdbc.Driver”

             url=”jdbc:mysql://localhost/dbase”    user=”root” password=”root”/>

             <sql:update dataSource=”${db}” var=”updt”>

                 INSERT INTO worker VALUES (‘Ashu’,’Area Manager’, 23, 18000);

             </sql:update>

                 <sql:query var=”dt” dataSource=”${db}”>

                     select * from worker

                 </sql:query>

                 <table border=”1″>

                  <tr>

                     <td><b>Name</b></td>

                     <td><b>Job</b></td>

                     <td><b>Age</b></td>

                     <td><b>Salary</b></td>

                  </tr>

                       <c:forEach var=”values” items=”${dt.rows}”>

                  <tr>

                     <td>${values.name}</td>

                     <td>${values.job}</td>

                     <td>${values.age}</td>

                     <td>${values.salary}</td>

                  </tr>

                       </c:forEach>

    </table>

  </body>

</html>

      JSTL SQL <sql:update> Tag

JSTL XML x:forEach Tag

By Dinesh Thakur

This tag used to create a loop over xml Documents this shows the value In which this is been implemented.

                                                         Worker.xml

<?xml version=”1.0″ ?>

<workers>

   <wrkr>

         <name>Raj</name>

         <age>23</age>

         <dob>12-07-1992</dob>

   </wrkr>

   <wrkr>

         <name>Suresh</name>

         <age>30</age>

         <dob>13-03-1984</dob>

   </wrkr>

   <wrkr>

      <name>Mohit</name>

      <age>20</age>

      <dob>10-05-1994</dob>

   </wrkr>

   <wrkr>

      <name>Ram</name>

      <age>35</age>

      <dob>1-03-1979</dob>

   </wrkr>

</workers>

……

                                                             forEach.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/xml” prefix=”x” %>

<html>

<head>

          <title>&lt;x:forEach&gt;Tags In JSTL</title>

</head>

     <body>

               <center><b><h3>Worker Info:</h3></b></center>

               <c:import url=”workers.xml” var=”lbr”/>

               <x:parse xml=”${lbr}” var=”disp”/>

        <ul class=”list”>

               <x:forEach select=”$disp/workers/wrkr/name” var=”prd”>

                   <center><b><li>Name Of Workers :<x:out select=”$prd” /></li></b></center>

               </x:forEach>

       </ul>

    </body>

    </html>

      JSTL XML < x:forEach > Tag

This program defines the working procedure of forEach tag. This tag is used to create a loop over XML doc. This will shows the result according to implemented condition. The main attribute of this tag is var ‘variable name’ that will use to access the tag and will store the fetched value on web browser. Xml file reference also been used as mention above.  All the tags must be closed at last.                             

JSTL XML x:set Tag

By Dinesh Thakur

 This tag use to set the variable attribute for initializing a value.

                                                           

                     Worker.xml

<?xml version=”1.0″ ?>

<workers>

   <wrkr>

         <name>Raj</name>

         <age>23</age>

         <dob>12-07-1992</dob>

   </wrkr>

   <wrkr>

         <name>Suresh</name>

         <age>30</age>

         <dob>13-03-1984</dob>

   </wrkr>

   <wrkr>

      <name>Mohit</name>

      <age>20</age>

      <dob>10-05-1994</dob>

   </wrkr>

   <wrkr>

      <name>Ram</name>

      <age>35</age>

      <dob>1-03-1979</dob>

   </wrkr>

</workers>

                                                             Set.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/xml” prefix=”x” %>

<html>

           <head>

                      <title>&lt;x:set&gt;Tag In JSTL</title>

           </head>

      <body>

                 <center><b><h3>Worker Info:</h3></b></center>

                 <c:import url=”workers.xml” var=”lbr”/>

                       <x:parse xml=”${lbr}” var=”disp”/>

                 <x:set var=”nm” select=”$disp//wrkr”/>

                      <center><b>The Age of the Third worker..

                 <c:out value=”${nm}”/></b></center>

      </body>

</html>

       JSTL XML < x:set > Tag

This program shows the use of set tag in this tag we set a var attribute used for variable name that will set a value for given condition. The main Attribute of this program is var ‘variable name’. The xml file also called named ‘workers.xml’. That will use to display the output on web browser.

JSTL XML x:Param Tag

By Dinesh Thakur

This tag casually used with <x:transform> tag this used to set parameter in XSL style sheet with in the reference of XML file in the Given tag.

                                                    Employee.xml 

<?xml version=”1.0″ ?>

<employee>

   <em>

        <name>Raj</name>

        <age>23</age>

        <dob>12-07-1992</dob>

   </em>

   <em>

        <name>Suresh</name>

        <age>30</age>

        <dob>13-03-1984</dob>

   </em>

   <em>

        <name>Mohit</name>

        <age>20</age>

        <dob>10-05-1994</dob>

   </em>

   <em>

        <name>Ram</name>

        <age>35</age>

        <dob>1-03-1979</dob>

   </em>

</employee>

                                                         Emp.xsl

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>

<xsl:output method=”xml” omit-xml-declaration=”yes” indent=”yes”/>

<xsl:param name=”first_color”/>

<xsl:param name=”second_color”/>

<xsl:param name=”third_color”/>

<xsl:template match=”employee”>

<html>

     <body>

                <center><h2>Workers Detail</h2></center>

                <table border=”1″>

                <tr>

                    <td align=”center”><b>Name</b></td>

                    <td align=”center”><b>Age</b></td>

                    <td align=”center”><b>D.O.B</b></td>

                </tr>

                    <xsl:for-each select=”em”>

               <tr>

                    <td bgColor=”{$first_color}”>

                        <i><xsl:value-of select=”name”/></i>

                    </td>

                    <td bgColor=”{$second_color}”>

                        <xsl:value-of select=”age”/>

                    </td>

                   <td bgColor=”{$third_color}”>

                        <xsl:value-of select=”dob”/>

                   </td>

                </tr>

        </xsl:for-each>

        </table>

       </body>

       </html>

      </xsl:template>

     </xsl:stylesheet>

                                                          Param.jsp

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

<%@ taglib prefix=”x” uri=”http://java.sun.com/jsp/jstl/xml” %>

<html>

     <head>

               <title>&lt;x:Param&gt; Tags In JSTL</title>

     </head>

          <body>

                <p><b><center><h3>Employee Data:</h3></center></b></p>

                <p><b><center><c:import url=”employee.xml” var=”xmlDoc” />

                <p><b><center><c:import url=”emp.xsl” var=”xslDoc” />

                <x:transform xml=”${xmlDoc}” xslt=”${xslDoc}”>

                <x:param name=”first_color” value=”#cccccc”/>

               <x:param name=”second_color” value=”#009900″/>

               <x:param name=”third_color” value=”#046280″/>

               </x:transform>

          </body>

   </html>

        JSTL XML < x:Param > Tag

This program will just show that how Param tag works this tag used to set the Parameter in XSL file like (coloring). All the content which will be fetched from the xml file or xsl file will be parameterized. The both files will be separated created as per mandatory requirement. Attributes also used to make this tag proper while compiling like var variable name that will store the value of statement in the end all the tags to be closed as per condition….

JSTL XML x:choose Tag

By Dinesh Thakur

This tag works with two other tags named <x: when>,<x:otherwise>. In other words if we define this tags resembles like switch statement from primitive JAVA code. User has to choose according to requirement which statement will be selected and run.

                                                      Worker.xml

<?xml version=”1.0″ ?>

<workers>

   <wrkr>

         <name>Raj</name>

         <age>23</age>

         <dob>12-07-1992</dob>

   </wrkr>

   <wrkr>

         <name>Suresh</name>

         <age>30</age>

         <dob>13-03-1984</dob>

   </wrkr>

   <wrkr>

      <name>Mohit</name>

      <age>20</age>

      <dob>10-05-1994</dob>

   </wrkr>

   <wrkr>

      <name>Ram</name>

      <age>35</age>

      <dob>1-03-1979</dob>

   </wrkr>

</workers>

                                                           Choose.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/xml” prefix=”x” %>

<html>

     <head>

            <title>&lt;x:choose&gt;,&lt;x:when&gt;,&lt;x:otherwise&gt; Tags In JSTL</title>

     </head>

         <body>

                <center><b><h3>Worker Info:</h3></b></center>

                <c:import url=”workers.xml” var=”lbr”/>

                <x:parse xml=”${lbr}” var=”disp”/>

                <x:choose>

                     <x:when select=”$disp//wrkr/name = ‘Raj'”>

                            <p><b><center>The First Worker is Raj</center></b></p>

                     </x:when>

                     <x:when select=”$disp//wrkr/name = ‘Suresh'”>

                            <br /><p><b><center>The Second Worker is Suresh</center></b></p>

                     </x:when>

                  <x:otherwise>

                        <br /><p><center><b>Finding….</b></center></p>

                  </x:otherwise>

                </x:choose>

         </body>

</html>

        JSTL XML < x:choose > Tag

As we discuss above that this tag is resembles to Switch statement of primitive java Code. In this program the Conditions are lying as their required place the selected condition will be display on output lane. If one does gone wrong the other one will be selected if nothing lied true the Otherwise Condition will run (default in Java Statement). The mandatory attributes are also used in the program like var the variable name that will represent the stored value in it. At last instance all the HTML tags will be closed.

JSTL XML x:out Tag

By Dinesh Thakur

This tag Is Used to Display the Output of Xpath on web browser.

                                                      Worker.xml

<?xml version=”1.0″ ?>

<workers>

   <wrkr>

         <name>Raj</name>

         <age>23</age>

         <dob>12-07-1992</dob>

   </wrkr>

   <wrkr>

         <name>Suresh</name>

         <age>30</age>

         <dob>13-03-1984</dob>

   </wrkr>

   <wrkr>

      <name>Mohit</name>

      <age>20</age>

      <dob>10-05-1994</dob>

   </wrkr>

   <wrkr>

      <name>Ram</name>

      <age>35</age>

      <dob>1-03-1979</dob>

   </wrkr>

</workers>

                                                                 Out.jsp

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/xml” prefix=”x” %>

<html>

    <head>

          <title>&lt;x:out&gt;Tags In JSTL</title>

    </head>

        <body>

            <center><b><h3>Worker Info:</h3></b></center>

            <c:import url=”workers.xml” var=”lbr”/>

                 <x:parse xml=”${lbr}” var=”disp”/>

            <center><b>The Name of the first Worker is</b>:

                 <x:out select=”$disp/workers/wrkr[1]/name” />  <br>

             <b>The Age of the second Worker</b>:

                <x:out select=”$disp/workers/wrkr[2]/age” /></center>

        </body>

</html>

       JSTL XML < x:out > Tag

In This Program we just present the working procedure of <x:out> tag. First we call the taglib code for JSTL accessing. Then after created XML file put in the variable that will fetched while compiling for output. Some mandatory attributes are also called. In the last we close all the HTML tags.

JSTL XML x:transform Tag

By Dinesh Thakur

This tag to use transforms the required Content from XML to XSL as we did in program. As Per condition we also create a XML File and a XSL file that will be represented on the web Browser as Output.

                                                      Worker.xml

<?xml version=”1.0″ ?>

<workers>

   <wrkr>

         <name>Raj</name>

         <age>23</age>

         <dob>12-07-1992</dob>

   </wrkr>

   <wrkr>

         <name>Suresh</name>

         <age>30</age>

         <dob>13-03-1984</dob>

   </wrkr>

   <wrkr>

      <name>Mohit</name>

      <age>20</age>

      <dob>10-05-1994</dob>

   </wrkr>

   <wrkr>

      <name>Ram</name>

      <age>35</age>

      <dob>1-03-1979</dob>

   </wrkr>

</workers>

                                                      Details.xsl

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>

<xsl:template match=”/”>

<html>

    <body>

         <center><h2>Detail Of Workers</h2></center>

         <table border=”1″>

         <tr>

              <td align=”center”><b>Name</b> </td>

              <td align=”center”><b>Age</b></td>

              <td align=”center”><b>D.O.B</b></td>

         </tr>

<xsl:for-each select=”workers/wrkr”>

         <tr>

            <td>

                   <xsl:value-of select=”name”/>

            </td>

            <td>

                  <xsl:value-of select=”age”/>

            </td>

            <td>

                  <xsl:value-of select=”dob”/>

            </td>

         </tr>

</xsl:for-each>

        </table>

    </body>

</html>

   </xsl:template>

   </xsl:stylesheet>

                                                             Transform.Jsp

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

<%@ taglib prefix=”x” uri=”http://java.sun.com/jsp/jstl/xml” %>

    <html>

          <head>

              <title>&lt;x:transform&gt;Tags In JSTL</title>

          </head>

             <body>

                  <center><b><h2>Workers Detail:</h2></b></center>

                  <c:import url=”workers.xml” var=”xmlDoc” />

                  <c:import url=”detail.xsl” var=”xslDoc” />

                   <x:transform doc=”${xmlDoc}” xslt=”${xslDoc}” />

             </body>

    </html>

        JSTL XML <x:transform> Tag

This Program created to define tag transform tag in XML criteria. First we have to call all the required Taglib for accessing JSTL codes. In this program we just transfer the contents from XML to XSL form. We need to create XML file as we did named ‘Workers.xml’ and the XSL file named “details.xsl”. Both Files will communicate while compiling and transfer the structure for output on the web browser. Required attributes are also used to access variables or contents. In the Last all the HTML tags will be closed.

JSTL XML x:if Tag

By Dinesh Thakur

This tag is to use to define the Control statements In JSP. Like to choose or select from conditional Criteria…!

                                                 “Voter.xml” (XML File for Program)

<?xml version=”1.0″ ?>

<voter>

<vote>

<name>Dev</name>

<age>18</age>

</vote>

<vote>

<name>Ashu</name>

<age>20</age>

</vote>

</voter>

                                                                 If.jsp            

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

<%@ taglib uri=”http://java.sun.com/jsp/jstl/xml” prefix=”x” %>

<html>

     <head>

           <title>&lt;x:if&gt;Tag In JSTL</title>

     </head>

       <body>

             <center><b><h3>Voting Eligibility</h3>

             <c:import url=”voter.xml” var=”vtr”/>

             <x:parse xml=”${vtr}” var=”disp”/>

             <x:if select=”$disp//vote”>

                  <p><center><b>Only One Can vote </b></center></p>

             </x:if> <br />

             <x:if select=”$disp/voter[1]/vote/age <= 18″>

                     <center><b><p>You can Vote…</p></b></center>

             </x:if>

        </body>

</html>

        JSTL XML <x:if> Tag

In This Program We Create a XML File as per Mention above named ‘Voter.xml’. That will be accessed while compiling the Program. Required attributes are also declared with the mandatory Variable. The Body section contains the main part of structure like Import URL will import the contents from XML file on The Web page. The Condition will be checked as per either the candidate will vote or not. In the Last all the tags will be closed.

JSTL Core fmt:timeZone Tag

By Dinesh Thakur

This tag In JSTL Library is Used to Show the time zone of Current Place of System or Internationalized Time Zone.

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

<%@ taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt” %>

<html>

      <head>

          <title>JSTL &lt;fmt:timeZone&gt; Tag Example</title>

      </head>

     <body>

           <br><p><center><b>Current Time zone’s Date & Time…</b></center></p>

           <c:set var=”tithi” value=”<%=new java.util.Date()%>” />

          <p><center><b><fmt:formatDate value=”${tithi}” type=”both”/></b></center></p>

          <p><center><b>Changed time zone’s Date & Time….</b></center></p>

          <p><center><b><fmt:timeZone value=”Canada/Eastern”></p></b></center>

          <p><b><center><fmt:formatDate value=”${tithi}” type=”both”/></center></b></p></br>

          </fmt:timeZone>

     </body>

</html>

       JSTL Tag <fmt:TimeZone>

This Program is an Example to Present The jstl Tag <fmt: TimeZone> in this Program we will Show the Current time zone value and Changed time zone value. First we all set to call JSTL Tag library then we use to declare variables that use to body in the function first we set to display the current time zone and next step we use to display changed time zone value. Then after we close all the required tags of HTML.

JSTL Core fmt:parseDate Tag

By Dinesh Thakur

This tag in JSTL is used to read(parsing) the Date as per required format Pattern. Attributes That are mandatory to use are avail in this tag like value or pattern. The main attribute Is pattern That will instruct that in which format the date will be displayed.

 

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

<%@ taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt” %>

<html>

     <head>

           <title>&lt;fmt:parseDate&gt; Tag In JSTL</title>

     </head

            <body>

                <b><center><h3>Displaying of Date Parsing In JSTL</h3>

                        <c:set var=”now” value=”2014-07-29″ />

                        <fmt:parseDate value=”${now}” var=”p_Date”  pattern=”yyyy-mm-dd” />

                <b><center><p>Parsed Date: <c:out value=”${p_Date}” /></p></center></b>

            </body>

</html>

       JSTL Tag <fmt:parseDate>

This program will use To explain the tag <fmt: parsedDate>. The tag library imported first as required as per condition then after declaring some mandatory variable with their respective attributes. The Body of program with HTML and JSTL tags the output is been displayed on the web browser. In the last we close all the tags.

JSTL Core fmt:parseNumber Tag

By Dinesh Thakur

This tag is Used to represent number as parsing Type like to display the number with decimal value or with only Integer type. As shown in the example below some attributes like value and var used to implement in that program. Var attribute use to store the variable value. Value will be use to assign the type of number.

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

<%@ taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt” %>

<html>

   <head>

          <title>JSTL Example of&lt;fmt:parseNumber&gt; Tag</title>

   </head>

       <body>

               <center><br><h3>Demo Of Number Parsing In JSTL:</h3></br></center>

                         <c:set var=”amt” value=”2370000.9866″ />

                               <fmt:parseNumber var=”bal” type=”number” value=”${amt}” />

               <b><center><p>Number Parsed (1) : <c:out value=”${bal}” /></p></center></b>

                               <fmt:parseNumber var=”bal” integerOnly=”true”

                                    type=”number” value=”${amt}” />

               <b><center><p>Number Parsed (2) : <c:out value=”${bal}” /></p>

       </body>

</html>

      JSTL Tag <fmt:ParsedNumber>

This Program is an example to represent the <fmt: ParsedNumber> tag. In this program we first use the JSTL tag Library to access the library as requirement. After that we declare the Variables which use to contain the stored value in the body section we use the JSTL tag with HTML code tags that will use to bring the output on the web browser. In the last we close all body parts of program(HTML).  

Next Page »

Primary Sidebar

Java Server Pages

Java Server Pages

  • JSP - Home
  • JSP - Advantages
  • JSP - Architecture
  • JSP - Life Cycle
  • JSP - Servlet Disadvantages
  • JSP - PrintWriter Vs JspWriter
  • JSP - Session Tracking
  • JSP - Stateless Protocol
  • JSP - Hidden Form Fields
  • JSP - Program Structure
  • JSP - Bill Discount Program
  • JSP - Scripting Elements
  • JSP - fn:length()
  • JSP - fn:split()
  • JSP - fmt formatNumber Tag
  • JSP - Servlet Communication
  • JSP - fn:replace()
  • JSP - fmt:parseNumber Tag
  • JSP - fmt:parseDate Tag
  • JSP - fn:substring()

Other Links

  • JSP - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW