import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

import HTML.*;

public class Example0402 extends HttpServlet {
//Initialize global variables

  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }
//Process the HTTP Post request

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = new PrintWriter (response.getOutputStream());

    HTMLDocument doc = new HTMLDocument("TEST Documet");

    HTMLText text = new HTMLText("Some Text.");
    text.setBold(true);
    text.setCenter(true);
    doc.addObject(text);

    doc.addObject(new HTMLLineBreak());
    
    doc.addObject(new HTMLHeading("Heading 4", HTMLHeading.H4));

    doc.addObject(new HTMLHorizontalRule());

    doc.addObject(new HTMLParagraph());

    HTMLImage wave = new HTMLImage("/images/tsunamiwave.gif", "Tsunami Wave");
    doc.addObject(wave);

    HTMLLink link = new HTMLLink("http://www.tsunami.com", new HTMLHeading("Heading 4", HTMLHeading.H4));
    doc.addObject(link);

    HTMLList list = new HTMLList();
    list.addObject(new HTMLText("Jim"));
    list.addObject(new HTMLImage("/images/tsunamiwave.gif", "Tsunami Wave"));

    doc.addObject(list);

    HTMLTable table = new HTMLTable();
    table.setCaption(new HTMLImage("/images/tsunamiwave.gif", "Tsunami Wave"));
    table.setBorder(1);
    
    HTMLTableRow row = new HTMLTableRow();
    HTMLTableCell cell = null;

    cell = new HTMLTableCell(HTMLTableCell.DATA);
    cell.addObject(new HTMLText("Cell 1"));
    row.addObject(cell);

    cell = new HTMLTableCell(HTMLTableCell.DATA);
    cell.addObject(new HTMLText("Cell 2"));
    row.addObject(cell);
    table.addObject(row);
    
    doc.addObject(table);

    HTMLForm form = new HTMLForm();
    form.setAction("/servlet/Example0402");
    form.setPostMethod(true);

    HTMLTextInput input = new HTMLTextInput();
    input.setName("Name");
    input.setSize(10);

    form.addObject(new HTMLText("Name : "));
    form.addObject(input);

    HTMLCheckBoxInput checkbox = new HTMLCheckBoxInput();
    form.addObject(checkbox);
    
    HTMLHiddenInput hidden = new HTMLHiddenInput();
    hidden.setName("Password");
    hidden.setValue("ygzwcxb");
    form.addObject(hidden);

    HTMLPasswordInput password = new HTMLPasswordInput();
    password.setName("Password");
    password.setSize(10);
    form.addObject(password);

    HTMLRadioButtonInput radiobutton = new HTMLRadioButtonInput();
    radiobutton.setName("OS");
    radiobutton.setValue("NT");
    radiobutton.setChecked(true);
    form.addObject(radiobutton);

    doc.addObject(form);
    
    out.println(doc.toHTML());
    
    out.close();
  }
//Get Servlet information
  
  public String getServletInfo() {
    return "Example0402 Information";
  }
}
 