
package rob.servlets.addressbook ;

import java.io.* ;
import java.util.* ;


/**
 * AppletLoginPage is the first page people see when they connect to the addressbook.
 *
 *
 * Created: Fri Mar  9 16:05:14 2001
 *
 * @author <a href="mailto: "Robert Judd</a>
 * @version
 */

public class AppletLoginPage {

    public AppletLoginPage() {}
    
    public void write(PrintWriter w) {
	for (int i=0, max=data.length; i<max; ++i) {
	    if (i != MESSAGE_LINE)
		w.println(data[i]) ;
	    else 
		w.println("Generated by AddressBookAppletServlet "+new Date().toString());
	}
	w.flush() ;
	w.close() ;
    }

    public static void main(String[] args) {

	try {
	    PrintWriter w ;
	    if (args[0].equals("-"))
		w = new PrintWriter(System.out) ;
	    else
		w = new PrintWriter(new FileWriter(args[0])) ;
	    for (int i=0, max=data.length; i<max; ++i) {
		if (i != MESSAGE_LINE)
		    w.println(data[i]) ;
		else 
		    w.println
			("Generated by AppletLoginPage "+new Date().toString()) ;
	    }
	    w.flush() ;
	    w.close() ;
	} catch (Exception ex) {
	    System.out.println
		("Usage: java rob.servlets.addressbook.AppletLoginPage ( filename | - )");
	}


    }

    public static final int MESSAGE_LINE = 67 ;
    public static final String[] data = new String[] {

	"<html>",
	"<head>",
	"",
	"<title>AddressBookAppletServlet Login</title>",
	"",
	"<script language=\"JavaScript\">",
	"",
	"<!--- Hide me",
	"// Check input fields and submit form.",
	"function checkLogin() {",
	"    // Make sure the userid field is not blank",
	"    if(document.login.userid.value.length == 0){",
	"        alert(\"The user id field should not be blank.\");",
	"        document.login.userid.focus();",
	"        return;",
	"    }",
	"    document.login.submit();",
	"    document.login.reset();",
	"}",
	"//End hiding-->",
	"",
	"",
	"</script>",
	"",
	"</head>",
	"<body bgcolor=\"#FFFFFF\" onLoad=\"document.login.userid.focus()\">",
	" ",
	"<table border=0 cellspacing=0 cellpadding=10 width=100% bgcolor=\"#767E9E\">",
	"  <tr><td align=center valign=center height=60><font color=\"#C2D7EA\" size=7>",
	"    <b>AddressBookAppletServlet Login</b></font></td></tr>",
	"</table>",
	"",
	"<br>",
	"",
	"<form method=\"POST\" name=\"login\" action=\"rob.servlets.addressbook.AddressBookAppletServlet\">",
	"",
	"<table>",
	"  <tr>",
	"    <td>User id: </td> ",
	"    <td><input maxlength=\"40\" type=\"text\" name=\"userid\" size=\"20\" value=\"\"></td>",
	"  </tr>",
	"  <tr>",
	"    <td>Password: </td>",
	"    <td><input maxlength=\"40\" type=\"password\" name=\"password\" size=\"20\" value=\"\"></td>",
	"  </tr>",
	"  <tr>",
	"    <td><input type=\"button\" onClick=\"checkLogin()\" value=\"Open\">",
	"	<input type=\"hidden\" name=\"action\" value=\"Open\"></td>",
	"    <td><input type=\"button\" onClick=\"reset()\" value=\"Reset\"></td>",
	"  </tr>",
	"</table>",
	"",
	"<noscript>",
	"If your browser does not support JavaScript use this button:",
	"<input type=\"submit\" value=\"Open\">",
	"</noscript>",
	"",
	"</form>",
	"",
	"<br>",
	"<table border=0 cellspacing=0 cellpadding=10 width=100% bgcolor=\"#767E9E\">",
	"  <tr><td align=right> &nbsp;",
	"  </td></tr>",
	"</table>",
	"<br>",
	"<address>",
	"<font color=\"#767E9E\">",
	"Generated by AddressBookAppletServlet Fri Mar  9 16:05:14 2001",
	"</font>",
	"</address>",
	"",
	"</body>",
	"</html>",
    } ;


}// AppletLoginPage
