home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / ExpirePage.java < prev    next >
Encoding:
Java Source  |  1997-09-05  |  1.1 KB  |  43 lines

  1. /**
  2.  * ExpirePage: Java dates can now be easily used with ASP, in this case 
  3.  * to set the page cache expiry date.
  4.  */
  5.  
  6. package IISSample;
  7.  
  8. import java.util.*;
  9. import aspcomp.*;
  10.  
  11.  
  12. public class ExpirePage 
  13. {
  14.  
  15.     public void expireAtYearEnd()
  16.     {
  17.         Response response = AspContext.getResponse();
  18.  
  19.         // Consider: using Calendar classes instead of Date
  20.  
  21.         Date now = new Date();
  22.  
  23.         Date nextYear = new Date(now.getYear() + 1,     // next year
  24.                                   0,                    // month
  25.                                   1,                    // day
  26.                                   0,                    // hours
  27.                                   0,                    // minutes
  28.                                   0);                   // seconds
  29.  
  30.         try
  31.         {
  32.             response.setExpiresAbsolute(nextYear);
  33.         }
  34.         catch(Exception e)
  35.         {
  36.             response.write(e.getMessage());
  37.         }
  38.  
  39.         response.write("The Expires: header has been set to: " + nextYear.toString() + "<P>");
  40.     }
  41.  
  42. }
  43.