how to send json data result from java servlet to javascript

Q

qingcai.wei

I am new to YUI. I looked the datatable example and likes it a lot.
The example used PHP

----------------------javascript side----------------------
this.myDataSource = new YAHOO.util.DataSource("assets/php/
json_proxy.php?");
this.myDataSource.responseType =
YAHOO.util.DataSource.TYPE_JSON;

----------------------PHP side-----------------------------
require_once('JSON.php');
$json = new Services_JSON();
echo ($json->encode($returnValue)); // Instead of json_encode

I wish I could do the same by using java servlet. Does any one have an
example or advice which can help me write some java code that can do
the same as the PHP code above does?

Thanks.
 
T

Tom Cole


There is a java library that will help you to write JSON in java. I
use it and it works very well. Of course you don't have to go this
route, you can simply send your response as valid JSON text with a
content-type of text/x-json...

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top