manniru
1/9/2015 - 8:00 PM

TwimlServlet.java

package com.twilio;

import java.io.IOException;

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

import com.twilio.sdk.verbs.Say;
import com.twilio.sdk.verbs.TwiMLResponse;

@SuppressWarnings("serial")
public class TwilioSandboxServlet extends HttpServlet {
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
		try {
			// Create a TwiML response and add our friendly message.
			TwiMLResponse twiml = new TwiMLResponse();
			Say say = new Say("Hello Monkey!");
			twiml.append(say);

			response.setContentType("application/xml");
			response.getWriter().print(twiml.toXML());

		} catch (Exception e) {
			e.printStackTrace();
			System.out.println(e);
		}
	}
}