home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / ExpirePage.java < prev    next >
Text File  |  1997-10-25  |  1KB  |  44 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.         GregorianCalendar now = new GregorianCalendar();
  20.  
  21.         // Calculate the begining of next year
  22.         GregorianCalendar nextYear = 
  23.             new GregorianCalendar(now.get(Calendar.YEAR) + 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.getTime());
  33.         }
  34.         catch(Exception e)
  35.         {
  36.             response.write(e.getMessage());
  37.         }
  38.  
  39.         response.write("The Expires: header has been set to: " 
  40.             + nextYear.getTime().toString() + "<P>");
  41.     }
  42.  
  43. }
  44.