Be happy with Java

毕设用Buffalo实时保存部分的代码写了71行,第一次:)

服务器端SimpleService.java
 1package net.buffalo.sei.simple;
 2import java.io.IOException;
 3import java.util.*;
 4import java.io.*;
 5
 6public class SimpleService{
 7    public static void main(String[] args) throws IOException{
 8/*        2.Input from memory
 9        StringReader in2=new StringReader(sHandle.value);
10        int c;
11        while((c=in2.read())!=-1)
12            System.out.print((char)c);
13        
14*/

15        
16//        4.File output
17        try{
18            BufferedReader in4=new BufferedReader(
19                    new StringReader(sHandle.value));
20            PrintWriter out1=new PrintWriter(
21                    new BufferedWriter(new FileWriter("Interval.xml")));
22            int lineCount=1;
23            while((s=in4.readLine())!=null)
24                out1.println(lineCount++ + ":"+s);
25            out1.close();
26        }
catch(EOFException e){
27            System.err.println("End of stream");
28        }

29    }

30}
浏览器端部分相关代码:)
 1<script language="JavaScript" src="script/prototype.js"></script>
 2<script language="JavaScript" src="script/buffalo.js"></script>
 3<script language="JavaScript" src="script/template.js"></script>
 4<SCRIPT language=javascript>
 5<!--
 6var endPoint="<%=request.getContextPath()%>/BUFFALO";
 7var buffalo = new Buffalo(endPoint);
 8function cmdSave() {
 9var sHandle = Buffalo.getElementById("description1");
10buffalo.remoteCall("simpleService.save",[buffalo:], function(reply) {
11  sHandle.value = reply.getResult();
12 }
)
13}

14//-->
15
</SCRIPT>
16
17<script language=javascript>
18<!--
19setInterval("cmdSave()",60000);
20-->
21
</script>
buffalo-service.properties
1# simpleService, The simple Service
2simpleService=net.buffalo.sei.simple.SimpleService
web.xml
 1<?xml version="1.0" encoding="UTF-8"?>
 2<!DOCTYPE web-app PUBLIC "-Sun Microsystems, Inc.DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
 3<web-app>
 4<display-name>Buffalo Demo-divide Application</display-name>
 5<servlet>
 6  <servlet-name>service</servlet-name>
 7  <servlet-class>net.buffalo.server.BuffaloServiceServlet</servlet-class>
 8  <init-param>
 9   <param-name>debug</param-name>
10   <param-value>true</param-value>
11  </init-param>
12</servlet>
13
14<servlet-mapping>
15  <servlet-name>service</servlet-name>
16  <url-pattern>/BUFFALO</url-pattern>
17</servlet-mapping>
18</web-app>
又是71行:)

posted on 2006-05-31 23:06 SYBIL@BLOGJAVA 阅读(135) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: