This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 1543
    
    1
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: 63227
    
  69

JSON


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

Joined: Nov 16, 2004
Posts: 1543
    
    1
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: 63227
    
  69

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Build Array in Servlet And Pass Back to Ajax Callback
 
It's not a secret anymore!