3

I have a JSP form element that looks like:

<form:input path="foo" id="bar" value="${myObject.myDate}" class="fizz buzz bang"/>

and I want to format this date so that it initially appears like: yyyy/mm/dd

I know I can format a date in JSP easily like this:

<fmt:formatDate value="${blah.bla}" pattern="MM-dd-yyyy" />

but how can I combine the two?

When I do:

 <form:input path="foo" id="bar" value=" <fmt:formatDate value="${myObject.myDate}" pattern="MM-dd-yyyy" /> " class="fizz buzz bang"/> 

I get exceptions on the line like:

org.apache.jasper.JasperException: Unterminated form:input tag

What am I doing wrong?

Paul
  • 3,318
  • 8
  • 36
  • 60

1 Answers1

6

You cannot directly use <fmt:formatDate> inside the form input tag. You can format it and assign the variable to value of form input.

<fmt:formatDate value="${blah.bla}" pattern="dd/MM/yyyy" var="myDate" />
<form:input path="foo" id="bar" value="${myDate} />

Hope this helps.

Community
  • 1
  • 1
Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
  • Ah... so it seems the actual problem here was me not knowing basic JSP syntax! Thanks for your help! – Paul May 04 '16 at 09:34