package hello;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
 
import com.twilio.sdk.verbs.TwiMLResponse;
import com.twilio.sdk.verbs.TwiMLException;
import com.twilio.sdk.verbs.Message;

import org.apache.log4j.Logger;

 
public class GrouperServlet extends HttpServlet {
 
    private static final Logger log = Logger.getLogger(Worker.class.getName());

    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
        org.apache.log4j.BasicConfigurator.configure();
        
        log.info("test");
        String phoneNumber = request.getParameter("From");
        String body = request.getParameter("body");
        Text text = new Text(phoneNumber, body);
        text.execute();
        TwiMLResponse twiml = new TwiMLResponse();
        Message message = new Message("Your message has been sent!");
        try {
            twiml.append(message);
        } catch (TwiMLException e) {
            e.printStackTrace();
        }
 
        response.setContentType("application/xml");
        response.getWriter().print(twiml.toXML());
    }
}
@@ -169,16 +169,48 @@
 eption;%0A
+%0Aimport java.util.Enumeration;%0A%0A
  %0Aimport
@@ -659,20 +659,16 @@
 ();%0A    
-    
 %0A       
@@ -672,22 +672,55 @@
     
-log.info(%22test
+String phoneNumber = request.getParameter(%22From
 %22);%0A
@@ -730,35 +730,28 @@
      String 
-phoneNumber
+body
  = request.g
@@ -755,36 +755,36 @@
 t.getParameter(%22
-From
+Body
 %22);%0A        Stri
@@ -780,52 +780,371 @@
     
+   
-   String body = request.getParameter(%22body%22
+%0A        //for testing!%0A        /* %0A        Enumeration%3CString%3E parameterNames = request.getParameterNames();%0A    %0A        while (parameterNames.hasMoreElements()) %7B%0A            String paramName = parameterNames.nextElement();%0A            log.info(paramName);%0A        %7D%0A        */%0A        %0A        log.info(%22body: %22 + body + %22 from phone number %22 + phoneNumber
 );%0A 

add logging