0

I have returned the object array from scriptlet,

<%       
List list =  new BaseHibernateDAO().executeSQLQuery(queryString);
Object[] data = (Object[])  list.get(0);
out.print(data);
%>

When i tried to get values in jquery it is not showing, $.ajax({ url: URL, success: function(data) { alert(data); } });

it is showing as => [Ljava.lang.Object;@22649e15

prakash
  • 13
  • 3
  • I imagine you're going to need to have an overriding `toString()` implementation. Having said that, in order for that to be invoked, you'll also need to return a more specific object type than Object. – Dan Temple Apr 25 '14 at 10:47

2 Answers2

0

default toString return classname +@ + hashcode.. You have to override toString method. refer this SO link..

Community
  • 1
  • 1
niiraj874u
  • 2,180
  • 1
  • 12
  • 19
0

A clean approach would be to use some JSON marshaller to convert your Java objects to JSON format. In Javascript you can easily process JSON as it is natively supported.

In Java EE 7 you can use the build-in JSON libraries (in earlier versions you can use e.g. Jackson):

JsonObject value = Json.createObjectBuilder()
     .add("field1", "1")
     .add("field2", "2")
     .build();

JsonWriter writer = Json.createWriter(out);
writer.writeObject(value);
Sebastian
  • 16,813
  • 4
  • 49
  • 56