// 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}");
}
}