import java.io.IOException;

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

import com.twilio.twiml.messaging.Body;
import com.twilio.twiml.messaging.Message;
import com.twilio.twiml.MessagingResponse;
import com.twilio.twiml.TwiMLException;

public class TwilioServlet extends HttpServlet {
  public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String body = request.getParameter("Body");
    String message = "Message";
    if (body == "hello") {
      // Use a generic message
      message = "Hi there!";
    } else if (body == "bye") {
      // Use the caller's name
      message = "Goodbye!";
    }

    // Create a TwiML response and add our friendly message.
    Body messageBody = new Body.Builder(message).build();
    Message sms = new Message.Builder().body(messageBody).build();
    MessagingResponse twiml = new MessagingResponse.Builder().message(sms).build();

    response.setContentType("application/xml");

    try {
      response.getWriter().print(twiml.toXml());
    } catch (TwiMLException e) {
      e.printStackTrace();
    }
  }
}

@@ -568,20 +568,24 @@
 body
- == 
+.equals(
 %22hello%22)
  %7B%0A 
@@ -580,16 +580,17 @@
 %22hello%22)
+)
  %7B%0A     
@@ -597,29 +597,14 @@
  // 
-Use a generic message
+Say hi
 %0A   
@@ -652,18 +652,23 @@
 body
- == 
+.equals(
 %22bye%22)
+)
  %7B%0A 
@@ -679,28 +679,18 @@
  // 
-Use the caller's nam
+Say goodby
 e%0A  

Use .equals instead of == to check message body