Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Build Array in Servlet And Pass Back to Ajax Callback

 
Steve Dyke
Ranch Hand
Posts: 1642
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSON
 
Steve Dyke
Ranch Hand
Posts: 1642
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic