Package projectatlast.tracking

Source Code of projectatlast.tracking.AjaxCurrentActivityServlet

package projectatlast.tracking;

import projectatlast.student.*;

import java.io.IOException;

import javax.servlet.http.*;

import com.google.appengine.repackaged.org.json.JSONException;
import com.google.appengine.repackaged.org.json.JSONWriter;

public class AjaxCurrentActivityServlet extends HttpServlet {

  private static final long serialVersionUID = 1L;

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    resp.setContentType("application/json");
   
    // Get current activity
    Student student = AuthController.getCurrentStudent();
    Activity activity = StudentController.getCurrentActivity(student);
   
    // Output as JSON
    JSONWriter writer = new JSONWriter(resp.getWriter());
    try {
      writer.object().key("activity");
      if(activity != null) {
        writer.value(activity.toJSON());
      } else {
        writer.value(null);
      }
      writer.endObject();
    } catch(JSONException e) {
      resp.getWriter().println("{\"activity\":null}");
    }
  }
}
TOP

Related Classes of projectatlast.tracking.AjaxCurrentActivityServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.