*
The moose likes JSP and the fly likes Build Array in Servlet And Pass Back to Ajax Callback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Build Array in Servlet And Pass Back to Ajax Callback" Watch "Build Array in Servlet And Pass Back to Ajax Callback" New topic
Author

Build Array in Servlet And Pass Back to Ajax Callback

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I want to create an array in my Servlet and send return that array in my callback string. I will use the arry to display several pdf files.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

JSON


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Bear Bibeault wrote:JSON


Okay this is part of my Servlet:



The jReturnString looks like this:

{"errorString": "NoError", "filePath": "["\/\/gvas400\/home\/ShippingDocssupport\/Temp\/ShippingDocs\/8130\/2011\/_185049_999999_SSR101911 CO185049_000143689.pdf","\/\/gvas400\/home\/ShippingDocssupport\/Temp\/ShippingDocs\/8130\/2011\/_185049_999999_SSR101911 CO185049_000143690.pdf","\/\/gvas400\/home\/ShippingDocssupport\/Temp\/ShippingDocs\/8130\/2011\/_185049_999999_SSR101911 CO185049_000143691.pdf"]"}

The JSON seems to be modifing the "\\"

Something is preventing my call back function from fireing.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Usually that means that the JSON is invalid.

I see that you are building your JSON by hand. Don't. Let a library such as Google's Gson handle the JSON conversion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Build Array in Servlet And Pass Back to Ajax Callback
 
Similar Threads
listen to events from a servlet in an embedded tomcat
jQuery load with Callback
Servlet can't get the xmlhttp post request
Passing a json object from servlet
Using Values in a List form one JSP to Another