package examples.htmlkona;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import weblogic.html.*;

/**
 * This servlet displays "Hello Universe" with a variety of
 * HTML text-level elements.
 * 
 * @author Copyright (c) 1996-98 WebLogic, Inc.  All Rights Reserved.
 * @author Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
 */
public class HelloUniverse extends HttpServlet {

  public synchronized void service(HttpServletRequest req, HttpServletResponse res) 
    throws IOException
  {
    try {
      res.setStatus(HttpServletResponse.SC_OK);
      res.setContentType("text/html");

      String caption = "Hello Universe!";

      ServletPage hp = new ServletPage();
      hp.getHead()
	.addElement(new TitleElement("Hello Universe"));
      hp.getBodyElement()
	.setAttribute(BodyElement.backgroundImg, defaults.imageloc() + "wtbkg.gif");
      hp.getBody()
        .addElement(MarkupElement.HorizontalLine)
        .addElement(new HeadingElement(caption, 1))
        .addElement(caption)                      
        .addElement(MarkupElement.Break)
        .addElement(new BoldElement(caption))    
        .addElement(new CenteredElement(caption))
	.addElement(new FontElement(4, HtmlColor.fuchsia, caption))
        .addElement(MarkupElement.Break)
	.addElement(new StrikeElement(caption))
        .addElement(MarkupElement.Break)
	.addElement(new UnderlineElement(caption))
        .addElement(MarkupElement.Break)
        .addElement(new ItalicElement(caption))  
        .addElement(new LiteralElement(caption)) 
        .addElement(new SuperscriptElement(caption)) 
        .addElement(caption)                      
        .addElement(new SubscriptElement(caption)) 
        .addElement(MarkupElement.Break)
        .addElement(new FontElement(5, caption).asItalicElement())
        .addElement(MarkupElement.Break)
        .addElement(new BoldElement(caption + " " + new ItalicElement(caption)))
        .addElement(MarkupElement.Break)
        .addElement(new LinkElement("HelloUniverse", caption).asBoldElement())
        .addElement(MarkupElement.HorizontalLine);

      OrderedList le = new OrderedList();
      for (int i = 1; i < 11; i++) 
        le.addElement(new ListItem(caption + " #" + i));

      hp.getBody()
        .addElement(le.asCenteredElement())
        .addElement(MarkupElement.HorizontalLine)
	.addElement("Copyright 1996-2000 by BEA Systems, Inc. All Rights Reserved.");

      hp.output(res.getOutputStream());
    }
    catch (Exception e) {
      defaults.showException(e, res.getOutputStream());
    }
  }
}
