Results 1 to 2 of 2

Thread: Servlet Will response JSON object and will read json object using sencha

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1

    Default Servlet Will response JSON object and will read json object using sencha


    I am new to Sencha touch , I am using this scripts in android sdk using phone gap frame work.

    I have implemented servlet which will respond JSON object.

    JSONServlet .java

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    * Servlet implementation class JSONServlet
    public class JSONServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    * @see HttpServlet#HttpServlet()
    public JSONServlet() {
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    PrintWriter out = response.getWriter();
    JSONArray arr = new JSONArray();
    JSONObject obj1 = new JSONObject();
    JSONObject obj2 = new JSONObject();
    JSONObject obj4 = new JSONObject();
    JSONObject obj5 = new JSONObject();
    JSONObject obj6 = new JSONObject();

    obj1.put("text", "abc");
    obj1.put("url", "");
    obj1.put("leaf", true);

    obj4.put("text", "klm");
    obj4.put("url", "");
    obj4.put("leaf", true);

    obj5.put("text", "xyz");
    obj5.put("url", "");
    obj5.put("leaf", true);

    obj6.put("text", "pqr");
    obj6.put("url", "");
    obj6.put("leaf", true);



    and In sencha script, I am calling the servlet and try to display the servlet output (Json format)

    onReady : function() {
    var cStore = new{
    autoLoad: true,
    proxy: {
    type: 'ajax',
    url: 'http://localhost:7001/JSONServlet/JSONServlet',
    reader: {
    type: 'json',
    root: 'items',
    totalProperty: 'results'
    ,fields: ['text', 'url']



    While executing the script i got below exception

    02-14 17:39:05.553: ERROR/Web Console(320): TypeError: Result of expression 'records' [undefined] is not an object. at file:///android_asset/www/sencha-touch-debug.js:7209

    I found one more thing , request is not hitting to the server

    help me on this , how to get the data?

  2. #2
    Sencha User
    Join Date
    Sep 2010



    your servlet should be just url: 'JSONServlet',

    I think your response type should be response.setContentType("application/json");

    I hope it helps

Similar Threads

  1. Problem in Gridpanel when there is single object in Json response.
    By anshu_gupta in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 9 Feb 2011, 3:26 AM
  2. Replies: 0
    Last Post: 15 Mar 2010, 2:39 PM
  3. how to enclose JSON object in response to Form submit error
    By angelflaree in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 22 Feb 2008, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts