Problem servlet server side processing

Problem servlet server side processing

legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
edited April 2014 in General
Hello,

i have this two codes:


[code]

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">





DataTables example

@import "media/css/demo_table.css";




var oTable;
$(function () {

oTable = $("#datatables").dataTable({
"sDom": 'TC<"clear">lfrtip',
"sPaginationType": "full_numbers",
"processing": true,
"bDeferRender": true,
"sAjaxSource": './connect',
"dataType": "json",
"aoColumns": [
{ "mData": "Vorname" },
{ "mData": "Nachname" },
{ "mData": "AliasName" } ],
"bServerSide": true,
"sServerMethod": "POST",

"oLanguage": {
"sProcessing": "Bitte warten...",
"sLengthMenu": "_MENU_ Einträge anzeigen",
"sZeroRecords": "Keine Einträge vorhanden.",
"sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen",
"sInfoEmpty": "0 bis 0 von 0 Einträgen",
"sInfoFiltered": "(gefiltert von _MAX_ Einträgen)",
"sInfoPostFix": "",
"sSearch": "Suchen",
"sUrl": "",
"oPaginate": {
"sFirst": "Erster",
"sPrevious": "Zurück",
"sNext": "Nächster",
"sLast": "Letzter"
}

},

"tableTools" : {
"sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
"aButtons": [

{
"sExtends": "collection",
"sButtonText": "Speichern als...",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "CSV"
},
{
"sExtends": "xls",
"sButtonText": "XLS"
},
{
"sExtends": "pdf",
"sButtonText": "PDF",
"sPdfOrientation": "landscape",
"sTitle": "Abfrage vom: ",
"sFileName": "*_Benjamin.pdf",
"sPdfMessage": "This is a testmessage.",
"mColumns": "sortable"

},
]
},

{
"sExtends": "print",
"sButtonText": "Drucken",
"sInfo": "Bitte nutzen Sie zum Drucken Ihren Broswer.\n Zum schließen 'ESC' drücken "
}
]
}

});

});

function druck()
{
var sData = oTable.$('input').serialize();
alert( "Folgende Zeile(n) wurden ausgewählt: \n\n"+sData );
return false;
}



.wrapper{width: 900px;margin: 0 auto;}









Vorname
Nachname
AliasName









[/code]

("tab.jsp")

[code]
package server;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

@WebServlet("/connect")
public class connect extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("application/json");
PrintWriter out = response.getWriter();

try{
Class.forName("com.jdbc.mysql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/personendaten?user=***&password=***");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM kunden");
JSONArray array = new JSONArray();
JSONObject zurueck = new JSONObject();
while(rs.next())
{
JSONObject object = new JSONObject();
object.put("vorname", rs.getString("Vorname"));
object.put("nachname", rs.getString("Nachname"));
object.put("aliasname", rs.getString("AliasName"));
array.add(object);
}
zurueck.put("aaData", array);
out.print(zurueck.toJSONString());
out.flush();

} catch(Exception e)
{
e.printStackTrace();
}

}
protected void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
doPost(request, response);
}
}



[/code]


But i get no results from the database.
All what i get is this error code: "dataTables warning(...)Invalid JSON response"


Why?

Thanks a lot.

Replies

  • ashiersashiers Posts: 101Questions: 8Answers: 7
    edited April 2014
    Show the JSON string that is being returned to the client side. From that we might be able to figure out what is going on. From initial inspection I would suspect that because you are not returning values for: iTotalRecords, iTotalDisplayRecords, and sEcho that DataTables is rejecting the JSON string. aaData is required, but that is not the only requirement.
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Ok i have set the things.

    Now looks like this:
    [code]
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page import="com.*,java.util.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">





    DataTables example

    @import "media/css/demo_table.css";




    var oTable;
    $(function () {

    oTable = $("#datatables").dataTable({
    "sDom": 'T<"clear">lfrtip',
    "bJqueryUI": true,
    "sPaginationType": "full_numbers",
    "processing": true,
    "bDeferRender": true,
    "sAjaxSource": 'server/connect',
    "dataType": "json",
    "sEcho": 10,
    "iTotalRecords": 50,
    "iTotalDisplayRecords": 10,
    "aaData":test,
    "aoColumns": [
    { "mData": "Vorname" },
    { "mData": "Nachname" },
    { "mData": "AliasName" }
    ],
    "bServerSide": true,
    "sServerMethod": "Get",


    "oLanguage": {
    "sProcessing": "Bitte warten...",
    "sLengthMenu": "_MENU_ Einträge anzeigen",
    "sZeroRecords": "Keine Einträge vorhanden.",
    "sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen",
    "sInfoEmpty": "0 bis 0 von 0 Einträgen",
    "sInfoFiltered": "(gefiltert von _MAX_ Einträgen)",
    "sInfoPostFix": "",
    "sSearch": "Suchen",
    "sUrl": "",
    "oPaginate": {
    "sFirst": "Erster",
    "sPrevious": "Zurück",
    "sNext": "Nächster",
    "sLast": "Letzter"
    }

    },

    "tableTools" : {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
    "aButtons": [

    {
    "sExtends": "collection",
    "sButtonText": "Speichern als...",
    "aButtons": [
    {
    "sExtends": "csv",
    "sButtonText": "CSV"
    },
    {
    "sExtends": "xls",
    "sButtonText": "XLS"
    },
    {
    "sExtends": "pdf",
    "sButtonText": "PDF",
    "sPdfOrientation": "landscape",
    "sTitle": "Abfrage vom: ",
    "sFileName": "*_Benjamin.pdf",
    "sPdfMessage": "This is a testmessage.",
    "mColumns": "sortable"

    },
    ]
    },

    {
    "sExtends": "print",
    "sButtonText": "Drucken",
    "sInfo": "Bitte nutzen Sie zum Drucken Ihren Broswer.\n Zum schließen 'ESC' drücken "
    }
    ]
    }

    });

    });

    function druck()
    {
    var sData = oTable.$('input').serialize();
    alert( "Folgende Zeile(n) wurden ausgewählt: \n\n"+sData );
    return false;
    }



    .wrapper{width: 900px;margin: 0 auto;}









    Vorname
    Nachname
    AliasName









    [/code]

    ("tab.jsp")

    and my servlet looks like this:

    [code]
    package server;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.json.simple.JSONArray;
    import org.json.simple.JSONObject;

    @WebServlet("/connect")
    public class connect extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {
    response.setContentType("application/json");
    PrintWriter out = response.getWriter();

    try
    {
    Class.forName("com.jdbc.mysql.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306 /personendaten?user=****&password=****");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM kunden");
    JSONArray array = new JSONArray();
    JSONObject back = new JSONObject();
    while(rs.next())
    {
    JSONObject object = new JSONObject();
    object.put("vorname", rs.getString("Vorname"));
    object.put("nachname", rs.getString("Nachname"));
    object.put("aliasname", rs.getString("AliasName"));
    array.add(object);
    }
    back.put("test", array);
    out.print(back.toJSONString());
    out.flush();

    } catch(Exception e)
    {
    e.printStackTrace();
    }

    }
    protected void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {
    doPost(request, response);
    }
    }


    [/code]

    I get now error message, but my table is still empty.
    I working with Java, so i don´t have a PHP File. Instead i have a SERVLET called ("connect").
    I want to connect to a mysql database,which is called 'personendaten'.
    I have import all JAR-Files etc.

    As I said, the table is still empty.
    By the way - I´m not a jerk in using dataTables, i just a beginner;-)

    Thanks...

    -legalizeSINCE88-
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    edited April 2014
    1. Are you using FireFox as your browser? If not, get FireFox and install FireBug (http://getfirebug.com/) to troubleshoot incoming JSON strings.
    You need to be able to see the JSON strings coming from the server.

    2. Originally your connect servlet had the line: zurueck.put("aaData", array);
    This was correct. DataTables expects aaData. But then you changed it to: back.put("test", array);
    This is incorrect. DataTables is not looking for "test", it is looking for "aaData".

    3. DataTables requires more than a value for "aaData". It also requires values for iTotalRecords, iTotalDisplayRecords, and sEcho.
    As an example, see this JSON String:

    {"aaData":[{"DT_RowId":"row_1","0":"All others","1":"Other browsers","2":"","3":"","4":"U"},
    {"DT_RowId":"row_2","0":"AOL browser(AOLdesktop)","1":"Trident","2":"Win XP","3":"6","4":"A"},
    {"DT_RowId":"row_3","0":"Camino 1.0","1":"Gecko","2":"OSX.2+","3":"1.8","4":"A"},
    {"DT_RowId":"row_4","0":"Camino 1.5","1":"Gecko","2":"OSX.3+","3":"1.8","4":"A"},
    {"DT_RowId":"row_5","0":"Dillo 0.8","1":"Misc","2":"Embedded devices","3":"","4":"X"},
    {"DT_RowId":"row_6","0":"Epiphany 2.20","1":"Gecko","2":"Gnome","3":"1.8","4":"A"},
    {"DT_RowId":"row_7","0":"Firefox 1.0","1":"Gecko","2":"Win 98+ / OSX.2+","3":"1.7","4":"A"},
    {"DT_RowId":"row_8","0":"Firefox 1.5","1":"Gecko","2":"Win 98+ / OSX.2+","3":"1.8","4":"A"},
    {"DT_RowId":"row_9","0":"Firefox 2.0","1":"Gecko","2":"Win 98+ / OSX.2+","3":"1.8","4":"A"},
    {"DT_RowId":"row_10","0":"Firefox 3.0","1":"Gecko","2":"Win 2K+ /OSX.3","3":"1.9","4":"A"}],
    "sEcho":1,"iTotalRecords":"57","iTotalDisplayRecords":"57"}

    Notice on the tail end of the JSON string the values for iTotalRecords, iTotalDisplayRecords, and sEcho. Those are important.
    See this page for details on each of these: http://datatables.net/usage/server-side
    Your servlet should be returning values for these as well as "aaData".
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Ok now my 'tab.jsp' looks like this:

    [code]
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">





    DataTables example

    @import "media/css/demo_table.css";




    var oTable;
    $(function () {
    oTable = $("#datatables").dataTable({
    "bProcessing": true,
    "sAjaxSource": 'connect',
    "bServerSide":true,
    "sDom": 'T<"clear">lfrtip',
    "bJqueryUI": true,
    "sPaginationType": "full_numbers",
    "aaData": back,
    "sEcho":3,
    "iTotalRecords":"1000",
    "iTotalDisplayRecords":"10",
    "aoColumns":
    [
    {"mdata": "vorname"},
    {"mdata": "nachname"},
    {"mdata": "aliasname"},
    {"mdata": "wohnort"},
    {"mdata": "geburtsdatum"},
    ],

    "oLanguage": {
    "sProcessing": "Bitte warten...",
    "sLengthMenu": "_MENU_ Einträge anzeigen",
    "sZeroRecords": "Keine Einträge vorhanden.",
    "sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen",
    "sInfoEmpty": "0 bis 0 von 0 Einträgen",
    "sInfoFiltered": "(gefiltert von _MAX_ Einträgen)",
    "sInfoPostFix": "",
    "sSearch": "Suchen",
    "sUrl": "",
    "oPaginate": {
    "sFirst": "Erster",
    "sPrevious": "Zurück",
    "sNext": "Nächster",
    "sLast": "Letzter"
    }

    },

    "tableTools" : {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
    "aButtons": [

    {
    "sExtends": "collection",
    "sButtonText": "Speichern als...",
    "aButtons": [
    {
    "sExtends": "csv",
    "sButtonText": "CSV"
    },
    {
    "sExtends": "xls",
    "sButtonText": "XLS"
    },
    {
    "sExtends": "pdf",
    "sButtonText": "PDF",
    "sPdfOrientation": "landscape",
    "sTitle": "Abfrage vom: ",
    "sFileName": "*_Benjamin.pdf",
    "sPdfMessage": "This is a testmessage.",
    "mColumns": "sortable"

    },
    ]
    },

    {
    "sExtends": "print",
    "sButtonText": "Drucken",
    "sInfo": "Bitte nutzen Sie zum Drucken Ihren Broswer.\n Zum schließen 'ESC' drücken "
    }
    ]
    }
    });
    });
    function druck()
    {
    var sData = oTable.$('input').serialize();
    alert( "Folgende Zeile(n) wurden ausgewählt: \n\n"+sData );
    return false;
    }



    .wrapper{width: 900px;margin: 0 auto;}









    Vorname
    Nachname
    AliasName
    Wohnort
    Geburtsdatum









    [/code]

    and my 'connect' - Servlet is this:

    [code]
    package server;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.json.simple.JSONArray;
    import org.json.simple.JSONObject;

    import com.google.gson.Gson;
    import com.google.gson.GsonBuilder;

    @WebServlet("/connect")
    public class connect extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {

    PrintWriter out = response.getWriter();

    try{
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8080/personendaten","****","****");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM personen");
    JSONArray array = new JSONArray();
    JSONObject back = new JSONObject();
    while(rs.next())
    {
    JSONObject object = new JSONObject();
    object.put("vorname", rs.getString("Vorname"));
    object.put("nachname", rs.getString("Nachname"));
    object.put("aliasname", rs.getString("AliasName"));
    object.put("geburtsort", rs.getString("Wohnort"));
    object.put("geburtsdatum", rs.getString("Geburtsdatum"));
    array.add(object);

    }

    back.put("aaData", array);
    out.print(back.toJSONString());
    out.flush();

    } catch(Exception e)
    {
    e.printStackTrace();
    }

    }

    protected void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {
    doPost(request, response);
    }
    }

    so i have debugg this code by' Firefox Debugger' as you said.
    The Debugger gives me the error, that he has no element found(for the request).
    And i ot the same error message like the last time:

    'DataTables warning:table id=datatables - Invalid JSON response'

    BUT - since you give me the tip for the "iTotalRecords","iTotalDisplayRecords" and "sEcho (i´v forgott the quotation marks..) the 'Processing' Label is shown until error message comes.

    Thanks a lot.

    -legalizeSINCE88-





    [/code]
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    edited April 2014
    NO,NO,NO. You have it wrong! Haven't you looked at some of the examples on this website? Check out example: http://datatables.net/release-datatables/examples/server_side/server_side.html

    Nowhere in the client-side initialization code does it have attributes: "iTotalRecords","iTotalDisplayRecords" and "sEcho". These properties are internal to DataTables and are to be set by the values you provide from the server-side, that is your servlet. Look at what those values represent in the documentation: http://datatables.net/usage/server-side and return them along with the "aaData". If you can't get that much right, then I can't help you any further.

    Think about what needs to be returned to the client side. Doesn't it make sense that you need to create a class that mimics the properties: "aaData", "iTotalRecords","iTotalDisplayRecords" and "sEcho"? And that the class has getter and setter methods for all of these? And that once you have all the properties set, all you have to do is pass an instance of the class as a parameter to a JSON Object? For instance:

    public class MyClass
    {
    private int sEcho = -1;
    private String iTotalRecords = "";
    private String iTotalDisplayRecords = "";
    private ArrayList aaData = new ArrayList();

    //Provide getters and setters
    }

    I see you've imported GSON. That's good because that is what I am familiar with. In your servlet using GSON from Google use the following pseudo code:

    MyClass clazz = new MyClass();
    ... set the properties
    GSon gson = new GSon();
    out.println(gson.toJSon(clazz));
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Ok now i have it changed:

    [code]

    package server;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.LinkedHashMap;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.json.simple.JSONArray;
    import org.json.simple.JSONObject;

    import com.google.gson.Gson;
    import com.google.gson.GsonBuilder;

    @WebServlet("/connect")
    public class connect extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private int TotalRecords = 7;
    private int Total = 7;


    @SuppressWarnings("unchecked")
    protected void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {
    response.setContentType("application/json");
    PrintWriter out = response.getWriter();
    try{
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8080/personendaten","***","***");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM personen");

    Pseudo ps = new Pseudo();
    LinkedHashMap list = new LinkedHashMap();

    while(rs.next())
    {
    list.put("vorname", rs.getString("Vorname"));
    list.put("nachname", rs.getString("Nachname"));
    list.put("aliasname", rs.getString("AliasName"));
    list.put("wohnort", rs.getString("Wohnort"));
    list.put("geburtsdatum", rs.getString("Geburtsdatum"));

    }

    ps.setAaData(list);
    ps.setiTotalDisplayRecords("7");
    ps.setiTotalDisplayRecords("7");

    Gson gson = new Gson();
    String json = gson.toJson(ps);
    out.print(json);

    } catch(Exception e)
    {
    e.printStackTrace();
    }

    }

    protected void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException
    {
    doGet(request, response);
    }
    }



    [/code]

    and here my "getter and setter" Class:

    [code]

    package server;

    import java.util.LinkedHashMap;

    public class Pseudo {
    private int sEcho = -1;
    private String iTotalRecords="";
    private String iTotalDisplayRecords="";
    private LinkedHashMap aaData;
    public int getsEcho() {
    return sEcho;
    }
    public void setsEcho(int sEcho) {
    this.sEcho = sEcho;
    }
    public String getiTotalRecords() {
    return iTotalRecords;
    }
    public void setiTotalRecords(String iTotalRecords) {
    this.iTotalRecords = iTotalRecords;
    }
    public String getiTotalDisplayRecords() {
    return iTotalDisplayRecords;
    }
    public void setiTotalDisplayRecords(String i) {
    this.iTotalDisplayRecords = i;
    }
    public LinkedHashMap getAaData() {
    return aaData;
    }
    public void setAaData(LinkedHashMap list) {
    this.aaData = list;
    }
    }


    [/code]

    and last but not least, my jsp file:

    [code]
    (...)


    $(function () {
    oTable = $("#datatables").dataTable({
    "bProcessing": true,
    "sAjaxSource": 'connect',
    "bServerSide":true,
    "bJQueryUI":true,
    "sPaginationType": "full_numbers",
    "aaData":"aaData",
    "aoColumns":
    [
    {"mdata": "Vorname"},
    {"mdata": "Nachname"},
    {"mdata": "AliasName"},
    {"mdata": "Wohnort"},
    {"mdata": "Geburtsdatum"},
    ],

    (...)
    [/code]

    Are the "iTotalRecords","iTotalDisplayRecords" and "sEcho" right setup?
    And how must is set the "aaData" in the JSP-File -or does it matter and i can remove it?

    I think we come to the end...soon;-)


    Many thanks for helping me!


    -legalizeSINCE88-
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    What does the returned JSON look like?
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Same error as start - "(..)invalid JSON response".
    Perhaps it may be, that i must set "JSONP" instead of "JSON" as response header?
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    If it is invalid JSON, what is it actually returning?
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    The exactly response from the server is: "SyntaxError:JSON.parse: unexpected end of data".
    That all - nothing else.
    But i don´t know where the error is.
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Here´s a link to images which i have made to show what´s going on

    http://img4web.com/g/GC7JV
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Your image shows that the server is not returning valid JSON. In fact it is not returning anything. I'm afraid we can't help you with that as this is not a Java programming forum. Ask somewhere like StackOverflow.

    Allan
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Incredible - i have it..ok almost.

    Now take a look at these Images please:

    http://img4web.com/

    As you can see, the returned JSON aaData is filled.
    My Table shows the current number of entries(left side)
    But the table itself remains empty.

    Please help me one more time.

    -legalizeSINCE88-
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    PS: Sorry wrong Link this is the right one:

    http://img4web.com/g/AY61D
  • legalizeSINCE88legalizeSINCE88 Posts: 16Questions: 1Answers: 0
    Right now i have this jsp file
    [code]
    <%@page import="server.Pseudo"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">





    DataTables example

    @import "media/css/demo_table.css";
    @import "media/css/demo_page.css";









    $(function () {
    oTable = $("#datatables").dataTable({
    "sDom": 'T<"clear">lfrtip',
    "bProcessing": true,
    "sAjaxSource": 'connect',
    "fnServerData": fnServerObjectToArray( [ 'vorname', 'nachname', 'aliasName', 'wohnort', 'geburtsdatum' ] ),
    "bServerSide":true,
    "bJQueryUI":true,
    "sPaginationType": "full_numbers",


    "oLanguage": {
    "sProcessing": "Bitte warten...",
    "sLengthMenu": "_MENU_ Einträge anzeigen",
    "sZeroRecords": "Keine Einträge vorhanden.",
    "sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen",
    "sInfoEmpty": "0 bis 0 von 0 Einträgen",
    "sInfoFiltered": "(gefiltert von _MAX_ Einträgen)",
    "sInfoPostFix": "",
    "sSearch": "Suchen",
    "sUrl": "",
    "oPaginate": {
    "sFirst": "Erster",
    "sPevious": "Zurück",
    "sNext": "Nächster",
    "sLast": "Letzter"
    }

    },

    "tableTools" : {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
    "aButtons": [

    {
    "sExtends": "collection",
    "sButtonText": "Speichern als...",
    "aButtons": [
    {
    "sExtends": "csv",
    "sButtonText": "CSV"
    },
    {
    "sExtends": "xls",
    "sButtonText": "XLS"
    },
    {
    "sExtends": "pdf",
    "sButtonText": "PDF",
    "sPdfOrientation": "landscape",
    "sTitle": "Abfrage vom: ",
    "sFileName": "*_Benjamin.pdf",
    "sPdfMessage": "This is a testmessage.",
    "mColumns": "sortable"

    },
    ]
    },

    {
    "sExtends": "print",
    "sButtonText": "Drucken",
    "sInfo": "Bitte nutzen Sie zum Drucken Ihren Broswer.\n Zum schließen 'ESC' drücken "
    }
    ]
    }
    });

    });

    fnServerObjectToArray = function ( aElements )
    {
    return function ( sSource, aoData, fnCallback ) {
    $.ajax( {
    "dataType": 'json',
    "type": "GET",
    "url": sSource,
    "data": aoData,
    "success": function (json) {
    var a = [];
    for ( var i=0, iLen=json.aaData.length ; i
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Your `aaData` there is an object. Not an array of objects.

    The server-side documentation and examples have been linked to in this thread before, I would suggest you read through them: http://datatables.net/usage/server-side . The documentation is provided to solve these issues. I'll be closing this thread soon.

    Allan
This discussion has been closed.