#### Example 1 - Server side JSP encoding #### service.jsp: ``` <%@page contentType="text/html; charset=UTF-8"%> <%@page import="org.json.simple.JSONObject"%> <% JSONObject obj=new JSONObject(); obj.put("name","foo"); obj.put("num",new Integer(100)); obj.put("balance",new Double(1000.21)); obj.put("is_vip",new Boolean(true)); obj.put("nickname",null); out.print(obj); out.flush(); %> ``` Please note that you need to place [json\_simple-1.1.jar](http://json-simple.googlecode.com/files/json_simple-1.1.jar) in WEB-INF/lib before running the JSP. Then the client side will get the resulting JSON text. #### Example 2 - Client side XMLHttpRequest #### client.html: ```
Click here to get JSON data from the server side ``` Please place client.html and service.jsp (see [Example 1](http://code.google.com/p/json-simple/wiki/JSPAndAJAXExamples#Example_1_-_Server_side_JSP_encoding)) in the same directory and then open client.html in IE or Firefox, click the link and you'll get result.