diff --git a/managed_vms/sendgrid/pom.xml b/managed_vms/sendgrid/pom.xml
index 32aa8b4a1f0..6a3c5e85cbd 100644
--- a/managed_vms/sendgrid/pom.xml
+++ b/managed_vms/sendgrid/pom.xml
@@ -48,9 +48,6 @@
1.8
-
org.eclipse.jetty
jetty-maven-plugin
diff --git a/managed_vms/sendgrid/src/main/java/com/example/managedvms/sendgrid/SendEmailServlet.java b/managed_vms/sendgrid/src/main/java/com/example/managedvms/sendgrid/SendEmailServlet.java
index d8efbd75edf..8e6f377f757 100644
--- a/managed_vms/sendgrid/src/main/java/com/example/managedvms/sendgrid/SendEmailServlet.java
+++ b/managed_vms/sendgrid/src/main/java/com/example/managedvms/sendgrid/SendEmailServlet.java
@@ -35,19 +35,19 @@ public class SendEmailServlet extends HttpServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
- final String SENDGRID_API_KEY = System.getenv("SENDGRID_API_KEY");
- final String SENDGRID_SENDER = System.getenv("SENDGRID_SENDER");
- final String TO_EMAIL = req.getParameter("to");
- if (TO_EMAIL == null) {
- resp.getWriter().print("Please provide an email address in the \"to\" query string"
- + " parameter.");
+ final String sendgridApiKey = System.getenv("SENDGRID_API_KEY");
+ final String sendgridSender = System.getenv("SENDGRID_SENDER");
+ final String toEmail = req.getParameter("to");
+ if (toEmail == null) {
+ resp.getWriter()
+ .print("Please provide an email address in the \"to\" query string parameter.");
return;
}
- SendGrid sendgrid = new SendGrid(SENDGRID_API_KEY);
+ SendGrid sendgrid = new SendGrid(sendgridApiKey);
SendGrid.Email email = new SendGrid.Email();
- email.addTo(TO_EMAIL);
- email.setFrom(SENDGRID_SENDER);
+ email.addTo(toEmail);
+ email.setFrom(sendgridSender);
email.setSubject("This is a test email");
email.setText("Example text body.");
@@ -58,8 +58,7 @@ public void service(HttpServletRequest req, HttpServletResponse resp) throws IOE
return;
}
resp.getWriter().print("Email sent.");
- }
- catch (SendGridException e) {
+ } catch (SendGridException e) {
throw new ServletException("SendGrid error", e);
}
}
diff --git a/managed_vms/twilio/pom.xml b/managed_vms/twilio/pom.xml
index 0eb2697c867..26fe22f51a1 100644
--- a/managed_vms/twilio/pom.xml
+++ b/managed_vms/twilio/pom.xml
@@ -48,9 +48,6 @@
1.8
-
org.eclipse.jetty
jetty-maven-plugin
diff --git a/managed_vms/twilio/src/main/java/com/example/managedvms/twilio/SendSmsServlet.java b/managed_vms/twilio/src/main/java/com/example/managedvms/twilio/SendSmsServlet.java
index 9b1ecb4ec63..5aa9977dd93 100644
--- a/managed_vms/twilio/src/main/java/com/example/managedvms/twilio/SendSmsServlet.java
+++ b/managed_vms/twilio/src/main/java/com/example/managedvms/twilio/SendSmsServlet.java
@@ -42,22 +42,21 @@ public class SendSmsServlet extends HttpServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
- final String TWILIO_ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
- final String TWILIO_AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");
- final String TWILIO_NUMBER = System.getenv("TWILIO_NUMBER");
- final String TO_NUMBER = (String) req.getParameter("to");
- if (TO_NUMBER == null) {
- resp.getWriter().print("Please provide the number to message in the \"to\" query string"
- + " parameter.");
+ final String twilioAccountSid = System.getenv("TWILIO_ACCOUNT_SID");
+ final String twilioAuthToken = System.getenv("TWILIO_AUTH_TOKEN");
+ final String twilioNumber = System.getenv("TWILIO_NUMBER");
+ final String toNumber = (String) req.getParameter("to");
+ if (toNumber == null) {
+ resp.getWriter()
+ .print("Please provide the number to message in the \"to\" query string parameter.");
return;
}
- TwilioRestClient client = new TwilioRestClient(TWILIO_ACCOUNT_SID,
- TWILIO_AUTH_TOKEN);
+ TwilioRestClient client = new TwilioRestClient(twilioAccountSid, twilioAuthToken);
Account account = client.getAccount();
MessageFactory messageFactory = account.getMessageFactory();
List params = new ArrayList();
- params.add(new BasicNameValuePair("To", TO_NUMBER));
- params.add(new BasicNameValuePair("From", TWILIO_NUMBER));
+ params.add(new BasicNameValuePair("To", toNumber));
+ params.add(new BasicNameValuePair("From", twilioNumber));
params.add(new BasicNameValuePair("Body", "Hello from Twilio!"));
try {
Message sms = messageFactory.create(params);