%@ page import="java.io.File" errorPage="err.jsp" %> <%@ taglib uri="gnat" prefix="gnat" %> <%-- Use the Servlet 2.2+ temporary working directory to demo some file stuff. Makes it easier because the user doesn't have to configure anything and I don't have to worry about file system and user permissions for the demo. See section 3.7 of Servlet 2.3 spec for description of this attribute. --%> <%! File tempdir = null; %> <% tempdir = (File)application.getAttribute("javax.servlet.context.tempdir"); %>
Changes the modification time of a file and possibly creates it at the same time. The touch examples in this page are created in <%= tempdir %>
<gnat:touch file="/file/to/touch" millis="modtime in millis" datetime="modtime date format"/>
example 1 - millis can be assigned dynamically, using an expression:
<gnat:touch file="<%= tempdir+foo %>" millis="<%= new java.util.Date().getTime() %>" />
example 2 - Or millis can be assigned statically, using milliseconds since midnight Jan 1 1970...
The example below sets the last modified time as 12/24/2000 21:15pm
<gnat:touch file="<%= tempdir+foo %>" millis="977710526363" />
example 3 - Or millis can be assigned statically, using a formatted date. The datetime variable must be set in format: MM/DD/YYYY HH:MM AM or PM.
<gnat:touch file="<%= tempdir+foo2 %>" datetime="06/28/1983 2:02 pm" />