/**
 * A simple servlet which stores all names entered and displays
 * them each time it is called.
 *
 * This file was automatically generated by
 * Omnicore CodeGuide.
 */

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * The servelet class.
 */
public class #project_name# extends HttpServlet
{
	/** A vector holding already entered names. */
	private Vector names = new Vector();
	
	
	/** Called when someone accesses the servlet. */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
    {
		// Get the name which was supplied when someone submitted the form.
		String name = request.getParameter("name");
		
		// If the name is null the servlet is shown for the first time.
		if (name != null) names.addElement(name);
		
		// Set content type for the browser.
		response.setContentType("text/html");
		
		// Print the static part of the web page
		PrintWriter out = response.getWriter();
		
		out.println("<html>");
		out.println("<head>");
		out.println("<title>#project_name#</title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<b> Enter your name and press Submit! </b>");
		out.println("<form action=\"#project_name#\" method=GET>");
		out.println("Your name:");
		out.print("<input type=text size=20 name=name");
		
		// If someone entered a name last time it is taken as the default value.
		if (name != null) out.print(" value=\""+name+"\"");
		
		out.println(">");
		out.println("<input type=submit value=Submit>");
		out.println("</form>");
		out.println("<hr><p>");
		
		// Print a list of already entered names.
		out.println("<b> Names already entered: </b>");
		out.println("<ul>");
		
		for(int i = 0; i < names.size(); i++)
		{
			out.println("<li> " + names.elementAt(i));
		}
		
		out.println("</ul>");
		out.println("</body>");
		out.println("</html>");
    }
}
