# @ Copyright 1998-2003 W3C (MIT, ERCIM, Keio), All Rights Reserved. See http://www.w3.org/Consortium/Legal/. 
// @ Copyright 1998-2003 W3C (MIT, ERCIM, Keio), All Rights Reserved. See http://www.w3.org/Consortium/Legal/. 
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 * Implement web service logic to support VoiceXML 2.0 Assertion 1a
 *
 * @author Dan Evans
 * @version 1.0, 08/15/2002
 */
public class A001aServlet extends HttpServlet
{
/**
 * Servlet initialization.
*/
public void
init(ServletConfig config) throws ServletException
{
 super.init(config);
}
/**
 * Handle the HTTP request regardless of method.
*/
public void
service(HttpServletRequest request,
    HttpServletResponse response) throws ServletException,
    IOException
{
 PrintWriter out;
 String rtncode;
 String ua;
 String meth;

 meth = request.getMethod();
 ua = request.getHeader("User-agent");
 if (!meth.equals("GET") && !meth.equals("POST"))
   rtncode = "3";
 else
 if (ua == null)
   rtncode = "1";
 else
  {
   if (ua.length() <= 0) // check for info
     rtncode = "2";
   else
     rtncode = null;
  }
 response.setContentType("text/xml"); // VoiceXML output
 out = response.getWriter();
 out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
 out.println("<vxml version=\"2.0\">");
 out.println("<form id=\"a001aReturn\">");
 out.println("<block name=\"a001aBlock1\">");
 if (rtncode == null)
   out.println("<return/>");
 else
  {
   out.println("<var name=\"error\" expr=\"" + rtncode + "\"/>");
   out.println("<return namelist=\"error\"/>");
  }
 out.println("</block>");
 out.println("</form>");
 out.println("</vxml>");
 out.close(); //end the document
}
/**
 * Servlet info.
*/
public String
getServletInfo()
{
 return "logic to support VoiceXML 2.0 Assertion 1a";
}
}
