This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Struts2 - Json problem  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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…



 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!