• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Struts2 - Json problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a ArrayList "objUsersList" in my Action class. That contains the following data.

objUsersList has setters and getters in my Action class.

[User [Nuser_id=1, strUser_FirstName=anil, strUser_LastName=mullapudi, strUser_Name=anil, strUser_Password=root, strUser_gender=M],
User [Nuser_id=2, strUser_FirstName=Ramesh, strUser_LastName=gubbala, strUser_Name=ramesh, strUser_Password=root, strUser_gender=M],
User [Nuser_id=3, strUser_FirstName=anil, strUser_LastName=vatti, strUser_Name=anilv, strUser_Password=root, strUser_gender=M],
User [Nuser_id=4, strUser_FirstName=ram, strUser_LastName=m, strUser_Name=ram, strUser_Password=root, strUser_gender=M],
User [Nuser_id=5, strUser_FirstName=tarun, strUser_LastName=k, strUser_Name=tarun, strUser_Password=root, strUser_gender=m]]


I am using the following code in my jsp.
java script:
-------------
function viewUsers() {

var url = 'view_users.action';

var myAjax = new Ajax.Request(
url,
{
method: 'post',
onComplete: fetchUsers
});

}

function fetchUsers(originalRequest) {
var result = originalRequest.responseText.evalJSON(); // the execution stops here
alert(result.objUsersList[0]);
}

How to populate my ArrayList in my jsp page. Please help me.

Thanks in advance.

I changed the above code to

function fetchUsers(originalRequest) {
alert(originalRequest.responseText);
}

Then i got the following execption in alert message


<html><head><title>Apache Tomcat/6.0.10 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: java.lang.reflect.InvocationTargetException
com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:239)
com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:95)
com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98)
com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony…



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic