Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how to send json data result from java servlet to javascript

Reply
Thread Tools

how to send json data result from java servlet to javascript

 
 
qingcai.wei@gmail.com
Guest
Posts: n/a
 
      03-07-2008
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.
 
Reply With Quote
 
 
 
 
Tom Cole
Guest
Posts: n/a
 
      03-08-2008
On Mar 7, 6:18*pm, qingcai....@gmail.com wrote:
>[snip]


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
 
Reply With Quote
 
 
 
 
Tom Cole
Guest
Posts: n/a
 
      03-08-2008
On Mar 7, 8:29*pm, Tom Cole <tco...@gmail.com> wrote:
> On Mar 7, 6:18*pm, qingcai....@gmail.com wrote:
>
> >[snip]

>
> 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


I could actually include the link, DUH...

http://www.json.org/java/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
"JSON for ASP" at json.org Tuğrul Topuz ASP General 1 06-27-2008 11:37 PM
how to send json data result from java servlet to javascript qingcai.wei@gmail.com Javascript 0 03-07-2008 11:17 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57