Expiring Page Sample

This sample shows you how to apply an expiration date to a particular Web page and specify an alternate page to serve when it expires.

Run this sample


How this sample works:

This sample has four parts:

  • An input form where you set the expiration date
  • The page that you want served up until the expiration date
  • The page you want served after the expiration date
  • A Java servlet that compares the expiration date to the current date and decides which page to serve

How to use this sample on your web page:

This sample uses an input form for demo purposes only. This is probably NOT the way you would implement this servlet on your own Web sites. Therefore, you will need to modify the Java servlet so that it does not expect the expiration date to come from an HTTP request. Instead, you can:

  • Put the date right into the servlet code
  • Read the date from another source, such as a database or another file

The Java servlet uses the callPage method and expects both the 'before' and 'after' pages to be JavaServlet Pages (JSPs). Using JSPs allows you to put dynamic data in these pages.