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 @ 2006-05-31 23:06 SYBIL@BLOGJAVA 阅读(136) | 评论 (0)编辑 收藏

5.19links

如何用正确的方法写出高质量软件的75条体会(粗粗的看了30条,就当是长见识和开阔思路用)

http://www.blueidea.com/tech/program/2006/3479.asp

posted @ 2006-05-19 13:33 SYBIL@BLOGJAVA 阅读(135) | 评论 (0)编辑 收藏

毕设代码改进版,写了71行:)

Item.java:)
 1package xml;
 2public class Item implements java.io.Serializable{
 3    private String input=null,output=null;
 4    public Item(String input,String output) 
 5    
 6        this.input=input; 
 7        this.output=output; 
 8    }
 
 9    public String getinput() 
10    
11        return input; 
12    }
 
13    public String getoutput() 
14    
15        return output; 
16    }
 
17}
ItemOption.java:)
 1package xml; 
 2import java.util.Iterator; 
 3import java.util.Vector; 
 4public class ItemOption implements java.io.Serializable 
 5    private Vector items=new Vector(); 
 6    public ItemOption() 
 7    
 8    }
 
 9    public Iterator getItems() 
10    
11        return items.iterator(); 
12    }
 
13    //增加vector中的对象 
14    public void addItem(String input,String output) 
15    
16        Object elements=new Item(input,output); 
17        items.addElement(elements); 
18    }
 
19    //移除vector中的对象 
20    public void delItem() 
21    
22        items.removeAllElements(); 
23    }
 
24}
 
25
tcxml.jsp:)
 1<%@ page contentType="text/html;charset=gb2312"%>
 2<%@ page import="xml.*"%>
 3<jsp:useBean id="ItemOption" scope="session" class=xml.ItemOption"/>
 4
 5    <%int tcnum=Integer.parseInt(request.getParameter("tcNum"));%>
 6    <count><%out.println("tcnum");%></count>
 7
 8    <% for(int i=1;i<=tcnum;i++){
 9        String textarea0=request.getParameter("textarea"+"i");
10        String textarea1=request.getParameter("textarea"+"i+1");
11    
12        ItemOption.addItem("textarea0","textarea1"); 
13    }
 %>
14    
15    <% 
16    java.util.Iterator Itvar=ItemOption.getItems() ; 
17    Item item=null
18    %>
19    
20    <%!int i=1%>
21    <%    while(Itvar.hasNext()) 
22    
23        item=(Item)Itvar.next(); 
24    %> 
25    <tc<%out.println(i); %>weight=<%Integer.parseInt(request.getParameter("weight13"));%>>
26    <input><%=item.getinput()%></input> 
27    <output> <%=item.getoutput()%> </output> 
28    <%i+=1;%>
29    </tc<%out.println(i); %>weight=<%Interger.parseInt(request.getParameter("weight13"));%>>
30    <%}
%>

我是在动态生成xml文件呢,呵呵,程序应该有好多错,有没人帮我挑挑呢?
XML文件格式是这样的:
 1<count>5</count>
 2<tc1 weight="0.2">        
 3    <input>输入</input>
 4    <output>期望输出</output>
 5</tc1> 
 6<tc2 weight="0.2">
 7    <input>输入</input>    
 8    <output>期望输出</output>
 9</tc2>
10<tc3 weight="0.2">
11    <input>输入</input>    
12    <output>期望输出</output>
13</tc3> 
14<tc4 weight="0.2">
15    <input>输入</input>    
16    <output>期望输出</output>
17</tc4> 
18<tc5 weight="0.2">
19    <input>输入</input>    
20    <output>期望输出</output>
21</tc5>  

posted @ 2006-05-15 22:33 SYBIL@BLOGJAVA 阅读(158) | 评论 (0)编辑 收藏

毕设代码写了二十一行:)

呵呵,有米人知道我写的是啥?

<% @ page contentType = " text/xml;charset= " gb2312 "  language= " java " %>
<%@ page import=
" java . io .* " %>
<html>
<head>
    <title>JDOM parse XML</title>
</head>
<body>
    <br>file2file.jsp动态生成XML文件</br>
    <%int tcnum=Integer.parseInt(request.getParameter(
" tcNum " ));%>
    <count><%out.println(
" tcnum " );%></count>
    
        <% for(int i=1;i<=tcnum;i++){%>   
            <tc<%out.println(i);%> weight=<%Integer.parseInt(request.getParameter(
" weight13 " ));%>>
                <%String textarea0=request.getPafameter(
" textarea " + " i " );%>
                <input><%out.println(
" textarea0 " );%></input>
                <%String textarea1=request.getPafameter(
" textarea " + " i + 1 " );%>
                <output><%out.println(textarea1);%></output>
            </tc<%out.println(i);%>>
    
</body>
</html>

posted @ 2006-05-14 22:33 SYBIL@BLOGJAVA 阅读(278) | 评论 (0)编辑 收藏

[5.1]links

百度首席架构师:算法是百度工程师的利器
http://community.csdn.net/Expert/topic/4680/4680082.xml?temp=.6066553


文件之间的链接

http://www.shanxiwindow.net/teaching/htmlbook/link01.htm

posted @ 2006-05-01 18:25 SYBIL@BLOGJAVA 阅读(92) | 评论 (0)编辑 收藏

4.29 links

表单提交中get和post方式的区别

http://www.weste.net/2006/1-11/14235072108.html

建一个XMLHttpRequest对象池
http://www.ugia.cn/?p=85

posted @ 2006-04-29 18:02 SYBIL@BLOGJAVA 阅读(170) | 评论 (0)编辑 收藏

4.28 links

PEAR简介:用PEAR来写你的下一个php程序

http://www-128.ibm.com/developerworks/cn/linux/sdk/php/pear1/index.html

才发现是01年的文章,不知道是不是过时了?不过今天面试时问道了require_once和include_once的问题,我发现我怎么总是现学现卖呢,怎么就没有以前的积累呢?

posted @ 2006-04-28 23:11 SYBIL@BLOGJAVA 阅读(122) | 评论 (0)编辑 收藏

推荐《ajax新手快车道》第二章四节内容

不知道适不适合高手,反正在我这样的web开发新手看来,有种醍醐灌顶的感觉

posted @ 2006-04-25 23:16 SYBIL@BLOGJAVA 阅读(152) | 评论 (0)编辑 收藏

4.24Blog Links

javascript的prototype

中国程序员的26种能力之六--不被别人替代的能力

中国程序员的26种能力之二 取信于人的能力

posted @ 2006-04-24 13:07 SYBIL@BLOGJAVA 阅读(122) | 评论 (0)编辑 收藏

4.22Blog Links

用HTML和CSS写出漂亮正规的BLOG
http://www.duduwolf.com/post/129.asp


Tag之死——来自spam的威胁?
http://www.duduwolf.com/post/133.asp

posted @ 2006-04-22 20:04 SYBIL@BLOGJAVA 阅读(108) | 评论 (0)编辑 收藏

仅列出标题
共5页: 上一页 1 2 3 4 5 下一页