content: /*
   * Gretty
   *
   * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
   *
   * See the file "LICENSE" for copying and usage permission.
   * See the file "CONTRIBUTORS" for complete list of contributors.
   */
  package org.akhikhl.examples.gretty.mywebservice;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class ExampleServlet extends HttpServlet {
  
    private static final long serialVersionUID = -6506276378398106663L;
  
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      PrintWriter out = response.getWriter();
      try {
        SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy");
        out.println("{ \"date\": \"" + format.format(new Date()) + "\" }");
      } finally {
        out.close();
      }
    }
  }
  