[opencms-dev] Re: lastModified Date in JSP Templates: How To..?

Christian Poecher Poecher at gmx.net
Thu Jan 20 20:42:42 CET 2005


Baader, Stefan wrote:
> I have not yet found any method to print the lastModified Date of a openCms
> page from the JSP template. I tried some Taglibs ans JARs, but only the
> beginning date of the Unix days is shown (1/1/1970). Does anybody know how
> to solve this?

We do it like this:

com.opencms.flex.jsp.CmsJspActionElement cms =
   new CmsJspActionElement(pageContext, request, response);
com.opencms.file.CmsObject cmsObject = cms.getCmsObject();

// Last Modified Date des bodys herausfinden
String path = cms.getRequestContext().getFolderUri();
String filename = cms.getRequestContext().getFileUri();
Vector files = cmsObject.getFilesInFolder(path);
boolean notFound = true;
int i = 0;
CmsResource ress = null;
while (notFound) {
   ress = (CmsResource) files.get(i);
   if (ress.getName().equals(filename))
     notFound = false;
   i++;
}
long modDate = ress.getDateLastModified();
String lastModreadable = Utils.getNiceDate(modDate);

hth, chris



More information about the opencms-dev mailing list