123456789101112131415161718192021222324 |
- package hello;
- import java.io.IOException;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- /**
- * JSON Encoding Test
- */
- @SuppressWarnings("serial")
- public class JsonServlet extends HttpServlet {
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
- IOException {
- // Set content type to JSON
- res.setHeader(Common.HEADER_CONTENT_TYPE, Common.CONTENT_TYPE_JSON);
- // Write JSON encoded message to the response.
- Common.MAPPER.writeValue(res.getOutputStream(), new Common.HelloMessage());
- }
- }
|