I have this code
<fmt:formatDate value="<%=new java.util.Date() %>" var="now" type="both"/>
<c:out value="${now }" />
which gives error
org.apache.jasper.JasperException: Unable to compile class for JSP
Now I have this code:
<c:set var="dd" value="<%=new java.util.Date() %>" />
<fmt:formatDate value="${dd}" var="now" type="both"/>
<c:out value="${now }" />
Which gives correct output:
Mar 22, 2017 10:09:24 PM
So my question is what is different in these two codes.
Edit 1: Complete code:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
The above mentioned codes were inserted here.
</body>
</html>