• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Tomcat 5.0.11 EL Feature is not working !!

kmthien

Senior member
Hi Guys,


MillenniumCounter.java
============================

package com.wrox.utilities;

import java.util.*;
import java.text.SimpleDateFormat;

public class MillenniumCounter
{
private SimpleDateFormat dateFormat;
private Calendar targetDate;

public MillenniumCounter()
{
dateFormat = new SimpleDateFormat("EEE, dd MMMM yyyy");

targetDate = Calendar.getInstance();
targetDate.set(targetDate.YEAR, 3000);
targetDate.set(targetDate.MONTH, 0);
targetDate.set(targetDate.DATE, 1);
targetDate.set(targetDate.AM_PM, 0);
targetDate.set(targetDate.HOUR, 0);
targetDate.set(targetDate.MINUTE, 0);
targetDate.set(targetDate.SECOND, 0);
}

public String getToday()
{
return dateFormat.format(new Date());
}

public long getDays()
{
Calendar now = Calendar.getInstance();
if (now.after(targetDate))
return 0;
else
{
long milliseconds = (targetDate.getTimeInMillis()
- now.getTimeInMillis());
long seconds = milliseconds / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;

return days;
}
}
}


MillenniumCounter.jsp
====================================

<html>
<head><title>Millennium Counter</title></head>
<body>

<jsp:useBean id="counter" scope="page"
class="com.wrox.utilities.MillenniumCounter"/>

The current date is ${counter.today}
<p/>
Only ${counter.days} days until the new millennium!

</body>
</html>


When I display the page, the result show :


The current date is ${counter.today}
Only ${counter.days} days until the new millennium!


Pls help !!
 
Back
Top