tags:

views:

5302

answers:

2

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.

+3  A: 

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.

Adeel Ansari
I don't remember if scope was required for useBean, but if it is, changing it to "page" may alleviate this issue.
MetroidFan2002
'scope' is not required.
Adeel Ansari
A: 

scope=page works for me