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

public class ByteGourmetServer extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        processRequest(request, response) ;
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        processRequest(request, response) ;
    }

    public void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        Enumeration e = request.getParameterNames();
        PrintWriter out = response.getWriter ();

        ByteGourmetMenuBean bgBean = new ByteGourmetMenuBean() ;

        while (e.hasMoreElements()) {
            String name = (String)e.nextElement();
            String value = request.getParameter(name);

        System.out.println(name + "\t" + value) ;

            if(name.equals("restaurant")) {
              if(value.equals("thaiPalace")) {
    
                ThaiPalaceMenuService service = new ThaiPalaceMenuService();
                ThaiPalaceMenuServicePortType port = service.getThaiPalaceMenuServicePort();
                bgBean.setMenu(port.getMenu()) ;
	          request.setAttribute ("menuBean", bgBean); 
                getServletConfig().getServletContext().getRequestDispatcher("/menu.jsp").forward(request, response); 
              }
            }
        }
        getServletConfig().getServletContext().getRequestDispatcher("/welcome.jsp").forward(request, response); 
       
    }
}
