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





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.