I would like to show the Last Modified Date of my JSP web page. I am using Tomcat Container located on Windows Server.
I am trying to use a Java Bean to show the last modified date.
My below attempt in the Bean class gives me errors with request object and I also need help in getting it to work. Please advise.
[code]
package data;
import java.io.*;
import java.text.*;
import java.util.*;
public class DateBean
{
private String mydate = “”;
public DateBean()
{
}
public String fetchDate(String mydate)
{
String jspPath =
getServletContext().getRealPath(request.getServletPath());
File jspFile = new File(jspPath);
Date lastModified = new Date(jspFile.lastModified());
SimpleDateFormat fmt = new SimpleDateFormat(“EEEE, MMMM dd, yyyy,
h:mm a(zz)”);
return fmt.format(lastModified);
}
public String getMydate()
{
return mydate;
}
public void setMydate(String mydate)
{
fetchDate(mydate);
this.mydate = mydate;
}
}