public
class
DataService
{
public
double
getData()
{
Random r
=
new
Random();
return
20
+
(
10
*
r.nextDouble()
-
5
);
}
public
static
void
main(String[] args)
{
DataService ds
=
new
DataService();
for
(
int
i
=
0
;i
<
20
;i
++
)
{
System.
out
.println(ds.getData());
}
}
}
Servlet上篇文章里有,我这里就不写了。
然后是一个html页面。
<
html
>
<
head
>
<
title
>
XML-RPC
</
title
>
<
script
type
="text/javascript"
src
="./js/init.js"
></
script
>
<
script
type
="text/javascript"
src
="./js/lib/urllib.js"
></
script
>
<
script
type
="text/javascript"
src
="./js/lib/xml.js"
></
script
>
<
script
type
="text/javascript"
src
="./js/lib/xmlrpc.js"
></
script
>
<
script
type
="text/javascript"
src
="./js/hello.js"
></
script
>
<
script
type
="text/javascript"
src
="./js/wz_jsgraphics.js"
></
script
>
</
head
>
<
body
onload
="init()"
>
<
input
type
="button"
id
="do3"
value
="start"
onclick
="startTimer()"
/>
<
input
type
="button"
id
="do3"
value
="stop"
onclick
="stopTimer()"
/>
<
input
type
="text"
id
="result"
/>
<
div
id
="canvas"
style
="border:1px solid #6666FF; position:relative;height:300px;width:500; background-color:#CCCCCC"
></
div
>
<
textarea
id
="debug"
rows
="10"
name
="S1"
cols
="69"
></
textarea
>
</
body
>
</
html
>