resp.setStatus(HttpServletResponse.SC_OK);
PrintWriter wrt = resp.getWriter();
wrt.write("[");
for (int i = 0; i < jobs.size(); i++) {
RecentJobEvent jobEvent = jobs.get(i);
//Serialize job to json
wrt.write("{");
wrt.write("\"jobid\": \"" + jobEvent.getJobID() + "\",");
if(jobEvent.getJobName() != null) {
wrt.write("\"jobname\": \"" + jobEvent.getJobName()+"\",");
}
wrt.write("\"status\": \""+ jobEvent.getJobStatus() + "\",");
wrt.write("\"time\": " + jobEvent.getTimestamp());
wrt.write("}");
//Write seperator between json objects
if(i != jobs.size() - 1) {
wrt.write(",");
}