Can anyone give me an example of how to return the following json simply from a jsp without any external libraries (except the ones that come standard with Oracle Java)?
From a JSP file, simplest way to create JSON output is using "json-taglib" library.
http://json-taglib.sourceforge.net/
All you'll have to do is:
1) Include the library jar file. You can either include it by downloading the jar file directly or by adding the pom dependency. Maven repo of this taglib can be found here; http://maven.nuxeo.org/nexus/content/repositories/public/atg/taglib/json/json-taglib/0.4.1/
2) Add following line in the taglib definition
3)Make sure the page output content type is json
4) Then just use the taglib
Here is a sample code
<%@page language="java" contentType="application/json;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>