Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing the current date using JSTL formatDate tag

Tags:

java

date

jsp

jstl

I am trying to show the current date in my JSP page using JSTL. below is the code I am using.

<jsp:useBean id="now" class="java.util.Date" scope="request" />
<fmt:formatDate value="${now}" pattern="MM.dd.yyyy" />

But the above code is not producing any results? Am I missing anything here or is there any better approach for this? I am using JSTL 1.1.

like image 967
Veera Avatar asked Jan 09 '09 11:01

Veera


People also ask

Which tag is used in JSTL to show the output?

The <c:out> tag is similar to JSP expression tag, but it can only be used with expression. It will display the result of an expression, similar to the way < %=... % > work.

What is the use of JSTL function tags?

JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.

What is JSTL FMT?

JSTL Core <fmt:message> Tag. The <fmt:message> tag is used for displaying an internationalized message. It maps the key of localized message to return the value using a resource bundle specified in the bundle attribute.


1 Answers

Try to print it without formatting, ${now}, you probably have null in there. Do you have this attribute in request scope? Just double check, if yes it might be null. If not, then try remove this scope attribute from the tag, yeah it doesn't matter but just to make the things clear.

like image 158
Adeel Ansari Avatar answered Sep 18 '22 15:09

Adeel Ansari