/*
 * ExternalServlet.java 1.00 27-Feb-2001
 *
 * Copyright 2000-2001 by Oracle Corporation
 * 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.
 * All rights reserved.
 */
package oracle.portal.sample.v2.devguide.externalApp;

import java.net.URL;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;

public class ExternalServlet extends HttpServlet
{

 /**
  * Constructor.
  */
  public ExternalServlet()
  {
  }

 /**
  * Public Method doGet handles the actual communication.
  *
  * Communicates with the ServletRunner and sets up the response
  * stream which gets sent to the parallel engine.
  *
  * @param  request Input Stream with the request information.
  * @param  response Output Stream for the resulting page.
  */
  public void doGet(HttpServletRequest request,
               HttpServletResponse response)
               throws MalformedURLException, IOException, ServletException
  {
    try
    {
      //Do get does little besides calling the process routine.
      new FlightDispatch(null).process(request, response);
    }
    catch (Exception e)
    {
      try
      {
        PrintWriter writer = response.getWriter();
        writer.println("An error has occured in this Application");
        e.printStackTrace(writer);
        writer.flush();
        writer.close();
      }
      catch (Exception ex)
      {
      //Do nothing here since this is just an example, however at this point
      //some time of error handling should be included in a robust system.
       }
    }
  }//doGet


 /**
  * 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 MalformedURLException, IOException, ServletException
  {
    //Call doGet
    doGet(request, response);
  }//doPut

 /**
  * init overrides the init function of the super.
  *
  * init initializes the servlet, and retrieves parameters from the
  * startup.
  */
  public void init(ServletConfig config) throws ServletException
  {
    super.init(config);
  }//init

}//ExternalServlet

