/* Copyright (c) 2001, 2002 Oracle Corporation. All Rights Reserved. */
package oracle.portal.sample.v2.devguide.partnerApp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Acts as the web application entry point to the Fancy Flights
 * application. Delegates to a {@link FlightDispatch} instance to perform
 * application logic.
 */
public class PartnerServlet extends HttpServlet
{
    // Fancy Flights application object which does all the work.
    private FlightDispatch mDispatcher;

    /**
     * Initializes this <code>PartnerServlet</code> by instantiating the {@link
     * FlightDispatch} object which will perform application logic.
     *
     * @param sc the <code>javax.servlet.ServletConfig</code>.
     * @exception <code>javax.servlet.ServletException</code> if an error
     * occurs while initializing.
     */
    public void init(ServletConfig sc) throws ServletException
    {
        super.init(sc);        
        mDispatcher = new FlightDispatch(null);
    }

    /**
     * Delegates to the Fancy Flights application object, {@link
     * FlightDispatch}, to process the request.
     *
     * @param request the <code>javax.servlet.http.HttpServletRequest</code>
     * object.
     * @param response the <code>javax.servlet.http.HttpServletResponse</code>
     * object.
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
    {
        mDispatcher.process(request,response);
    }

    /**
     * Public Method doPost handles the actual communication.
     *
     * Communicates with the ServletRunner and sets up the response
     * stream which gets sent to the parallel engine.
     *
     * @param  request request information.
     * @param  response resulting page.
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
    {
        doGet(request, response);
    }

}
