Below is the example code to responding to JSON in a server-side JSP script. It shows how to set up the JSON text, HTTP header and jsoncallback. I hope you don't waste time.
<%@ page language="java" import="net.sf.json.JSONObject" %> <%@page import="java.util.*" %> <% response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); JSONObject object=new JSONObject(); object.put("key", "value"); String jsoncallback = request.getParameter("jsoncallback"); response.getWriter().println(jsoncallback + "(" + object.toString()+");"); %>
thanks a million. I didn't need the JSONObject, just put the JSON-data instead of object.toString()
ReplyDeletei'm glad I could help :) as you said, just putting the JSON data is also OK bc JSON is a text-based language.
ReplyDelete