tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kazuaki Miyauchi <miyau...@gmail.com>
Subject How to convert String to Date in EL?
Date Mon, 19 Aug 2019 03:45:32 GMT
 I made following JSP.

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<html>
<head>
  <title>Insert Date</title>
</head>
<body>

<c:catch var="ex">
<sql:setDataSource dataSource="jdbc/kome" var="kome"/>
<sql:update var="stmt" dataSource="${kome}">
 insert into test values(?,?)
 <sql:dateParam value="2019-8-19" type="DATE"/>
 <sql:param value="Good Day"/>
</sql:update>
</c:catch>

<c:if test="${not empty ex}">
 <c:out value="${ex}" />
</c:if>
</body>
</html>

Table was simply made as following.
create table test (when_cause date, how text);

 Then, I got following error in tomcat-9.0.22.
org.apache.jasper.JasperException: Unable to convert string
[2019-8-19] to class [java.util.Date] for attribute [value]: [Property
Editor not registered with the PropertyEditorManager]

 How to convert String date data to Date type?

 After changing as following, it works.
But, it's not easily readable when making complicated sql.

<sql:update var="stmt" dataSource="${kome}">
 insert into test values('2019-8-19',?)
 <sql:param value="Good Day"/>
</sql:update>

Regards,                         Kazuaki Miyauchi, Japan

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@tomcat.apache.org
For additional commands, e-mail: taglibs-user-help@tomcat.apache.org


Mime
View raw message