package com.dummy.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TigerServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = -2468770581631627665L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("***TIGER Servlet***");
/*
[
{
"company": 'tiger',
"price": 99999,
"change": 0.04,
"pctChange": 0.05,
"lastChange": '9/1 12:00am'
},
{
"company": 'cat jerry',
"price": 22.56,
"change": 1.85,
"pctChange": 3,
"lastChange": '11/2 12:00am'
}
]
StringBuffer sb = new StringBuffer("[{");
sb.append("\"company\": 'tiger',");
sb.append("\"price\": 99999,");
sb.append("\"change\": 0.04,");
sb.append("\"pctChange\": 0.05,");
sb.append("\"lastChange\": '9/1 12:00am'");
sb.append("},{");
sb.append("\"company\": 'cat jerry',");
sb.append("\"price\": 22.56,");
sb.append("\"change\": 1.85,");
sb.append("\"pctChange\": 3,");
sb.append("\"lastChange\": '11/2 12:00am'");
sb.append("}]");
*/
StringBuffer sb = new StringBuffer("[{");
sb.append("\"company\": \"tiger\",");
sb.append("\"price\": 99999,");
sb.append("\"change\": 0.04,");
sb.append("\"pctChange\": 0.05,");
sb.append("\"lastChange\": '9/1 12:00am'");
sb.append("},{");
sb.append("\"company\": \"cat jerry\",");
sb.append("\"price\": 22.56,");
sb.append("\"change\": 1.85,");
sb.append("\"pctChange\": 3,");
sb.append("\"lastChange\": '11/2 12:00am'");
sb.append("}]");
resp.getWriter().write(sb.toString());
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
this.doGet(req, resp);
}
}