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><sql:dateParam>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>