
package rob.servlets.addressbook ;

import java.io.* ;
import java.util.* ;
import java.net.URLEncoder ;

/**
 * AppletPage 
 *
 *
 * Created: Fri Mar  9 16:05:14 2001
 *
 * @author <a href="mailto: "Robert Judd</a>
 * @version
 */





public class AppletPage {

    private String userid ;
    

    public  AppletPage(String userid) {
	this.userid = userid ;
    }
    
    public void write(PrintWriter w) {
	for (int i=0, max=data.length; i<max; ++i) {
	    if (i == USERID_LINE)
		w.println("<PARAM NAME=\"userid\" VALUE=\""+userid+"\">") ;
	    else if (i == MESSAGE_LINE)
		w.println("Generated by AddressBookServlet "+new Date().toString());
	    else 
		w.println(data[i]) ;
	}
	w.flush() ;
	w.close() ;
    }
	
    
    public static void main(String[] args) {

	try {

	    PrintWriter w ;
	    if (args == null || args.length == 0 ||args[0].equals("-"))
		w = new PrintWriter(System.out) ;
	    else
		w = new PrintWriter(new FileWriter(args[0])) ;

	     AppletPage ep = new  AppletPage("Doh!") ;
	    ep.write(w) ;

	} catch (Exception ex) {
	    System.out.println
		("Usage: java rob.servlets.addressbook. AppletPage ( filename | - )");
	}


    }

    public static final int USERID_LINE = 10 ;
    public static final int MESSAGE_LINE = 15 ;
    public static final String[] data = new String[] {

	"<HTML>",
	"<HEAD>",
	"<TITLE>Addressbook Applet</TITLE>",
	"",
	"</HEAD>",
	"",
	"<BODY BGCOLOR=\"#FFFFFF\">",
	"<CENTER><H1>Addressbook Applet</H1></CENTER>",
	"",
	"<APPLET CODE=\"rob.applets.addressbook.AddressbookApplet.class\" ARCHIVE=\"/addressbookApplet.jar\" WIDTH=\"700\" HEIGHT=\"250\">",
	"<PARAM NAME=\"userid\" VALUE=\"no-one\">",
	"</APPLET>",
	"",
	"<HR>",
	"<ADDRESS><BR>",
	"Generated by AddressBookAppletServlet Sun Apr  8 10:18:09 CDT 2001",
	"</ADDRESS>",
	"</BODY>",
	"</HTML>"
    } ;


}// AppletPage 

