Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

play-framework getting the last-modification date for file

PlayFramework application, the footer.html file:

%{
 file = new File("footer.html");
 path = file.getCanonicalPath();
 lm = file.lastModified();
 // date = new Date(lm);
}%

<span> Last update: ${lm} </span>

Here I have right path, so the footer.html is exist.

But the lm is 0 i.e. it is 1970 year.. but now is 2011.

The question: why? Can it be related somehow to security-manager or something related to security?

like image 902
ses Avatar asked Nov 04 '22 12:11

ses


1 Answers

Can you check ${file.exists()}?

I think what's happening is that your file "footer.html" does not exists, because play will use compiled views (usually on temp/bytecode/DEV folder), and in the compiled views, this file does not exists

Even if you change to the compiled filename it would not work on the server, because modification date of the file on the build would be the date of the build.

like image 52
Felipe Avatar answered Nov 09 '22 13:11

Felipe