URL分别用三个List保存,
一个是boring,这个list中的url最后来下载
其他两个是interesting和average
当搜索到url时检查是否包含设定为boring的词,并放入boring中

用户可设定“深度搜索”:每搜到一个url就放在list的最前面
也可广度

有些网页链接要特殊处理:

url = textReplace("?", URLEncoder.encode("?"), url);
url = textReplace("&", URLEncoder.encode("&"), url);
private String textReplace(String find, String replace, String input)
{
    int startPos = 0;
     while(true)
    {
        int textPos = input.indexOf(find, startPos);
        if(textPos < 0)
        {
            break;
        }
        input = input.substring(0, textPos) + replace + input.substring(textPos + find.length());
        startPos = textPos + replace.length();
    }
    return input;
}

读取资源代码:

BufferedInputStream remoteBIS = new BufferedInputStream(conn.getInputStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
byte[] buf = new byte[1024];
int bytesRead = 0;
while(bytesRead >= 0)
{
    baos.write(buf, 0, bytesRead);
    bytesRead = remoteBIS.read(buf);
}

byte[] content = baos.toByteArray();


建立多级目录:

File f = new File(fileName);
f.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(fileName);
out.write(content);
out.flush();
out.close();


给一个变量写doc:(在eclipse中,鼠标置上会显示)

/**
* Set of URLs downloaded or scheduled, so we don't download a
* URL more than once.
* Thread safety: To access the set, first synchronize on it.
*/
private Set urlsDownloadedOrScheduled;


这种log挺好:(apache log4j)

private final static Category _logClass = Category.getInstance(TextSpider.class);

/*
显示信息: 2005-05-01 11:40:44,250 [main] INFO? TextSpider.java:105 - Starting Spider...
*/
_logClass.info("Starting Spider...");

posted @ 2006-02-16 14:10 罗明 阅读(560) | 评论 (0)编辑 收藏
 
当下载第一个URL时(一般是网站主页),如果等待时间过长,那么其他线程要么会认为网站已下载完而结束,要么会在下面标*代码处抛出NullPointerException, 很少能够存活下来。

else if(queueSize() == 0)       /* queueSize()已经被同步 */
{
    break;
}
URLToDownload nextURL;
synchronized(queue)
{
    nextURL = queue.getNextInQueue();
    downloadsInProgress++;
}
synchronized(urlsDownloading)
{
    urlsDownloading.add(nextURL);
}
int newDepth = nextURL.getDepth() + 1; **********************


估计可能是线程交叉了,还没来得及同步就跑到后面去执行getDepth()了。
nextURL = queue.getNextInQueue();后面加上判断就OK了:

synchronized(queue)
{
    nextURL = queue.getNextInQueue();
    if(nextURL == null)
    {
        continue;
    }

    downloadsInProgress++;
}


posted @ 2006-02-16 14:10 罗明 阅读(1022) | 评论 (0)编辑 收藏
 

I had to get obsessed with keyboard shortcuts when using IDEA.
Apparently some of that must have rubbed off, because
lately I've been looking for shortcuts to methods and classes in Eclipse 3.0.

There are two traversal shortcuts I use all the time: Ctrl-O and Ctrl-T.

Ctrl-O shows the methods of the class in the current editor in a popup.
Hit Ctrl-O when the popup is up, and you'll see all the inherited
methods as well. This is incredibly useful, as it allows me to bounce
between methods even when I'm not sure which class is implementing
which method.

Ctrl-T shows the type hierarchy of a selected type in a popup. This is the
complement to Ctrl-O. When I'm sure of what
interface I'm looking at, but I really want to pick a particular implementation
and want to go trawling through that
implementation for a bit, Ctrl-T will show me all the subclasses or
implementors for that type.

There is a third option which I haven't used much. Ctrl-F3 shows the
methods of a selected type in a popup. I can see how this can be useful,
but in practice I have a pretty good idea of which methods are attached
 to which classes and Ctrl-Space fills most of my needs there.

However, I have been missing a couple of things. These are the shortcuts
I just found recently, and are very good for hitting up random files:

Ctrl-E shows a popup list of all the open files.
Ctrl-Shift-T creates a dialog box that you can use to navigate to any class.
Ctrl-Shift-R creates a dialog box that shows any resource in the project
(basically any file.)
Alternately, there's an Eclipse plugin called GotoFile which seems to behave
a little more "IDEAish".

Finally, I found a plugin which actually integrates Eclipse with Windows!
Eclipse Platform Extensions is actually functional and useful, although
you wouldn't guess it by looking at the website. Although it says that
it provides a "System GC" functionality, it actually does far more,
like provide a "Open in Windows Explorer" and
"Open Command Window here" dialog to the Package Explorer.

posted @ 2006-02-16 14:09 罗明 阅读(290) | 评论 (0)编辑 收藏
 

Installing the help system as an infocenter

You can allow your users to access the help system over the Internet or an intranet, by
installing the infocenter and the documentation plug-ins on a server. Clients view help
by navigating to a URL, and the help system is shown in their web browser. The
infocenter help system can be used both for client applications and for web
applications, either of which can have their help accessed remotely. All features
of help system except infopops and active help are supported.

The infocenter help system allows passing number of options that can be used to
customize various aspects of the infocenter. The following options are supported:

  • -eclipsehome eclipseInstallPath - specifies Eclipse installation directory.
    This directory is a parent to "plugins" directory and eclipse executable.
    The option must be provided, when current directory from which infocenter
    is launched, is not the same as Eclipse installation directory.
  • -data instanceArea - specifies a path that Eclipse can use to write instance data.
    The value can be an absolute path of a directory, or a path relative to Eclipse
    installation directory. The option must be provided when Eclipse is installed in
    the read only location, or has been customized to override osgi.instance.area
    or osgi.instance.area.default properties.
  • -host helpServerHost - specifies host name of the interface that help server
    will use. It overrides host name specified in the application server plugin preferences.
  • -port helpServerPort - specifies port number that help server will use. It overrides
    port number specified in the application server plugin preferences.
  • -locales localeList - specifies a list of locales that infocenter will recognize and
    provide a customized content for. If the option is not specified, infocenter will
    build navigation, and index documents for each preferred locale of the browsers
    accessing the infocenter. When the option is present, locales from browser
    requests will be matched with locales in the list. If browser preferred locale
    does not exist in the list, but its language part does, it will be used. Subsequently,
    additional browser locales in decreased order of preference will be matched
    against the list. If none of the browser locales (or its language part) matches any
    locale on the list, the client will be served content in the default locale - server
    locale or locale passed with -nl option. For example using options
    -nl en -locales de en es fr it ja ko pt_BR zh_CN zh_TW
    will cause infocenter operating in 10 locales. All other locales will receive content
    for en locale.
  • -dir rtl - sets right-to-left rendering direction of help UI in the browser.
  • -noexec - indicates that Eclipse executable should not be used. You may need to use
    this option when running on a platform for which Eclipse executable is not available.
  • Additionally, most options accepted by Eclipse executable can be passed. They are
    especially useful during debugging and for applying customization to Eclipse.
    For example, passing options
    -vmargs -Xmx256M 
    increases memory available to the infocenter and will allow serving a larger book collection.

Installation/packaging

These steps are for the help system integrator and are not meant to address all the possible scenarios.
 It is assumed that all your documentation is delivered as Eclipse plug-ins and, in general, you are
familiar with the eclipse help system.

  1. Download the Eclipse Platform Runtime Binary driver from www.eclipse.org.
  2. Install (unzip) the driver in a directory, d:\myApp. This will create an eclipse sub-directory,
    d:\myApp\eclipse that contains the code required for the Eclipse platform
    (which includes the help system).

How to start or stop infocenter from command line

The org.eclipse.help.standalone.Infocenter class has a main method that you can use to
launch infocenter from a command line. The command line arguments syntax is:

-command start | shutdown | [-eclipsehome eclipseInstallPath] 
[-data instanceArea] [-host helpServerHost] [-locales localeList]
[-port helpServerPort] [-dir rtl] [-noexec] [platform options]
[-vmargs JavaVMarguments]

To start an infocenter on port 8081 issue a start command by running

java -classpath d:\myApp\eclipse\plugins\org.eclipse.help.base_3.1.0.jar 
org.eclipse.help.standalone.Infocenter -command start -eclipsehome
d:\myApp\eclipse -port 8081

To shut the infocenter down issue a shutdown command by running

java -classpath d:\myApp\eclipse\plugins\org.eclipse.help.base_3.1.0.jar 
org.eclipse.help.standalone.Infocenter -command shutdown -eclipsehome
d:\myApp\eclipse

Using the infocenter

Start the web server. Point a web browser to the path "help" web application running on a port
specified when starting the infocenter.  On the machine the infocenter is installed, this would be
http://localhost:8081/help/.

How to start or stop infocenter from Java

When including infocenter as part of another application, it may be more convenient to start it
and stop using Java APIs instead of using system commands. Follow the steps if it is the case:

  1. Make sure d:\myApp\eclipse\plugins\org.eclipse.help.base_3.1.0.jar is on your app classpath.
    The class you use to start, and shut down the infocenter isorg.eclipse.help.standalone.Infocenter.
  2. Create an array of String containing options that you want to pass to the infocenter. Typically,
    the eclipsehome and port options are needed.
    String[] options = new String[] { "-eclipsehome", "d:\\myApp\\eclipse" ,
    "-port", "8081" };
  3. In your application, create an instance of the Help class by passing the options.
    Infocenter infocenter = new Help(options); 
  4. To start the help system:
    helpSystem.start();
  5. To shut the infocenter down:

    helpSystem.shutdown(); 

Making infocenter available on the web

Eclipse contains a complete infocenter and does not require other server software to run.
However, in unsecure environment like Internet, it is recommended infocenter is not accessed
directly by clients, but is made available through an HTTP server or an application server.
Most servers come with modules or servlets for delegating certain request to other web
resources. For example, one may configure a proxy module of Apache HTTP Server to
redirect requests made to http://mycompany.com/myproduct/infocenter to
http://internalserver:8081/help that runs an infocenter. Adding the lines

LoadModule proxy_module modules/ApacheModuleProxy.dll
ProxyPass /myproduct/infocenter http://internalserver:8081/help
ProxyPassReverse /myproduct/infocenter http://internalserver:8081/help
to conf/httpd.conf file of Apache server running mycompany web site accomplishes this.

Some versions of Apache HTTP server, may contain AddDefaultCharset directive enabled in
configuration file. Remove the directive or replace with

AddDefaultCharset Off
to have browsers display documents using correct character set.

Running multiple instance of infocenter

Multiple instances of infocenter can be run on a machine from one installation. Each started
instance must use its own port and be provided with a workspace, hence -port and -data
options must be specified. The instances can serve documentation from different set of plug-ins,
by providing a valid platform configuration with -configuration option.

If -configuration is not used and configuration directory is shared among multiple infocenter
instances, with overlapping set of locales, it must be ensured that all search indexes are created
by one infocenter instance before another instance is started. Indexes are saved in the configuration
directory, and write access is not synchronized across infocenter processes.

[Optional] Installing a minimal set of plug-ins

The infocenter does not require the entire  Eclipse Platform package. It is possible to run the
infocenter with the following plug-ins (located in the  eclipse\plugins directory):

org.apache.lucene
org.eclipse.core.runtime
org.eclipse.help
org.eclipse.help.appserver
org.eclipse.help.base
org.eclipse.help.webapp
org.eclipse.osgi
org.eclipse.tomcat
org.eclipse.update.configurator

Some documentation plug-ins may have dependencies on other plug-ins, usually by specifying required
plug-ins in their plugin.xml. The dependent plug-ins need to be installed on the infocenter as well.
Additionally, plug-ins that were designed for earlier than 3.0 version of Eclipse implicitly require an org.eclipse.core.runtime.compatibility being present plug-in to work.

Infocenter plug-ins can be updated without restarting the infocenter, using commands explained
in Updating a running infocenter from command line topic. To use this functionality, the minimal
set of plug-ins must include org.eclipse.update.core plug-in.

See Help System Preferences for more information on customizing help system.

posted @ 2006-02-16 14:08 罗明 阅读(469) | 评论 (0)编辑 收藏
 
Class.forName is excellent
例:

Class.forName("weblech.util.Log4j");

在Log4j里定义一个静态类构造器,里面放apache log4j的初始代码。

其他如注册数据源、界面本地化。。。

Eclipse看代码是最爽的:
查看类的引用、代码导航
posted @ 2006-02-16 14:07 罗明 阅读(224) | 评论 (0)编辑 收藏
 

      调试网页时出错,无意中发现出错页的源文件中有这样一段注释:

<title>404 Not Found</title>
<h1>404 Not Found</h1>
/asfsfdsd.jsp was not found on this server.
<p /><hr />
<small>
Resin 2.0.3 (built Wed Oct 17 10:11:08 PDT 2001)
</small>
</address>

<!--
  -- Unfortunately, Microsoft has added a clever new
  -- "feature" to Internet Explorer.  If the text in
  -- an error's message is "too small", specifically
  -- less than 512 bytes, Internet Explorer returns
  -- its own error message.  Yes, you can turn that
  -- off, but *surprise* it's pretty tricky to find
  -- buried as a switch called "smart error
  -- messages"  That means, of course, that many of
  -- Resin's error messages are censored by default.
  -- And, of course, you'll be shocked to learn that
  -- IIS always returns error messages that are long
  -- enough to make Internet Explorer happy.  The
  -- workaround is pretty simple: pad the error
  -- message with a big comment to push it over the
  -- five hundred and twelve byte minimum.  Of course,
  -- that's exactly what you're reading right now.
  -->

这就叫以牙还牙:凡是用Resin服务器的网站,都不会出现M$的恼人友好信息了。

posted @ 2006-02-13 18:27 罗明 阅读(925) | 评论 (0)编辑 收藏
 
以前一直没找到这个选项,以为不可以呢。终于发现工具菜单-->选项里的“播放机设置”栏的第一个复选框就是设置将播放器置于最前端。写出来怕大家有需要的^_^
posted @ 2006-02-12 16:35 罗明 阅读(724) | 评论 (1)编辑 收藏
 
Bill Scott's AJAX Blog: Nine Tips for Designing Rich Internet Applications
If you were going to provide some quick basic guidelines for designing rich applications what would they be?

posted @ 2006-01-09 17:16 罗明 阅读(395) | 评论 (0)编辑 收藏
 
源多说明通过你的apt能安装更多软件,如果下列链接有效,就将它加到你的sources.list (注意顺序,将速度最快的放在最前头,apt会默认用前面的链接下载软件)

deb ftp://ftp.sjtu.edu.cn/sites/archive.ubuntu.com breezy main restricted universe multiverse
deb ftp://ftp.sjtu.edu.cn/sites/archive.ubuntu.com breezy-updates main restricted universe multiverse
deb ftp://ftp.sjtu.edu.cn/sites/archive.ubuntu.com breezy-security main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu breezy main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu breezy-updates main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu breezy-security main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu-cn breezy main universe multiverse restricted
deb http://archive.ubuntu.org.cn/ubuntu hoary main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu hoary-security main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu hoary-updates main restricted universe multiverse
deb http://archive.ubuntu.org.cn/ubuntu-cn ubuntu.org.cn main universe multiverse restricted
deb http://archive.ubuntu.org.cn/ubuntu hoary-backports main universe multiverse restricted
deb http://archive.ubuntu.org.cn/backports hoary-extras main universe multiverse restricted
deb-src http://archive.ubuntu.org.cn/ubuntu hoary main restricted universe multiverse
deb-src http://archive.ubuntu.org.cn/ubuntu hoary-security main restricted universe multiverse
deb-src http://archive.ubuntu.org.cn/ubuntu hoary-updates main restricted universe multiverse
deb http://helix.alioth.debian.org/deb sid main non-free
deb-src http://helix.alioth.debian.org/deb sid main non-free
deb http://ubuntu.cn99.com/ubuntu/ breezy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ breezy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ breezy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ breezy main restricted universe multiverse
deb http://ubuntu.cn99.com/backports/ breezy-extras main restricted universe multiverse
posted @ 2006-01-07 17:02 罗明 阅读(2005) | 评论 (0)编辑 收藏
 
Source: http://openide.netbeans.org/tutorial/api-design.html#design.less.friend
Allow access only from a friend code
Another useful technique to not expose too much in API is to give access to certain functionality (e. g. ability to instantiate a class or to call a certain method) just to a friend code.

Java by default restricts the friends of a class to those classes that are in the same package. If there is a functionality that you want share just among classes in the same package, use package-private modifier in definition of a constructor, a field or a method and then it will remain accessible only to friends.

Sometimes however it is more useful to extend the set of friends to a wider range of classes - for example one wants to define a pure API package and put the implementation into separate one. In such cases following trick can be found useful. Imagine there is a class item:

public final class api.Item {
    /** Friend only constructor */
    Item(int value) {
        this.value = value;
    }

    /** API method(s) */
    public int getValue() {
        return value;
    }
        
    /** Friend only method */
    final void addListener(Listener l) {
        // some impl
    }
}
that is part of the API, but cannot be instanitated nor listened on outside of the friend classes (but these classes are not only in api package). Then one can define an Accessor in the non-API package:
public abstract class impl.Accessor {
    public static Accessor DEFAULT;

    static {
        // invokes static initializer of Item.class
        // that will assign value to the DEFAULT field above
        Class c = api.Item.class;
        try {
            Class.forName(c.getName(), true, c.getClassLoader());
        } catch (ClassNotFoundException ex) {
            assert false : ex;
        }
        assert DEFAULT != null : "The DEFAULT field must be initialized";
    }

    /** Accessor to constructor */
    public abstract Item newItem(int value);
    /** Accessor to listener */
    public abstract void addListener(Item item, Listener l);
}
with abstract methods to access all friend functionality of the Item class and with a static field to get the accessor's instance. The main trick is to implement the Accessor by a (non-public) class in the api package:
final class api.AccessorImpl extends impl.Accessor {
    public Item newItem(int value) {
        return new Item(value);
    }
    public void addListener(Item item, Listener l) {
        return item.addListener(l);
    }
}
and register it as the default instance first time somebody touches api.Item by adding a static initializer to the Item class:
public final class Item {
    static {
        impl.Accessor.DEFAULT = new api.AccessorImpl();
    }

    // the rest of the Item class as shown above
}
Then the friend code can use the accessor to invoke the hidden functionality from any package:
api.Item item = impl.Accessor.DEFAULT.newItem(10);
impl.Accessor.DEFAULT.addListener(item, this);
posted @ 2006-01-05 21:01 罗明 阅读(407) | 评论 (0)编辑 收藏
 
[新华社]singlerly被双规

    1月3日Man版消息。北京时间14点左右Man版传出消息,来自紫丁香的singlerly日前在 
Man版被双规。 
    当地官员发言指出,该嫌疑犯是因为煽动灌水而于当天14点左右被捕的。目前正于押解 
前往xiaoheiwu的途中。 
    据当地群众称,当地政府的权力混乱局面是singlerly同志遭到双规的主要原因。很多群众对singlerly的双重不幸报以同情和羡慕。 
    另有一位不愿透露姓名的权威人士指出,造成这种混乱局面的原因是由于相亲的处理问题,现在值班站务jimu小同学已基本控制了换乱的局面。 
    新华社驻Man版记者cc现场为您报道。 
Re

感谢前方记者为我们带来的现场报道 

现在是广告时间 
广告过后请继续关注
Re

下面继续播报最新新闻: 

丁香社哈尔滨1月3日电(记者八卦王子) 

谈天聊地实习片长jimu日前表示,目前8区关税人员关系总体稳定,但斑竹和水友 
和谐制度落实不到位、斑竹增长和调控机制不健全、侵害灌水者合法权益等问题 
仍然比较突出。  

  

jimu表明在第十一个五年规划里借助改革深入攻坚战,要基本解决斑竹缺额问题。 

他进一步提出,要针对当前的突出矛盾,以建立和谐稳定的灌水关系为主线,以 
维护最广大的关税者合法权益为重点,积极探索、创新校内BBS先进平台条件下和 
谐灌水关系和管理版面体制和机制。 
Re

本报讯  斑竹多id灌水是为了反恐 

1月4日 紫丁香站长lanslot在听证会上被问及:每个斑竹允许同时登陆3个帐号,免费获取 
上站时间和文章数,这是为了减轻紫丁香系统负担么? 
lanslot说:“众所周知,目前国际恐怖势力猖獗,bbs又是恐怖分子的重点袭击对象,所 
以必须加强bbs反恐力度,bbs斑竹义不容辞地担负起bbs义务安全员的重要职责。”
Re

bbs 八卦报消息:关闭bbs是为了刷水箱 

5月5日 紫丁香全面关闭,据紫丁香总管popstar称:由于战友灌水过多,导致紫丁香系统 
水垢严重,暂时关闭紫丁香3天,清除水垢。具体放水时间另行通知。 

另有消息说,本次关站与紫丁香上游水母厂爆炸有关。水母厂技术站长接受本报记者采访 
时称:“爆炸只产生了二氧化碳和水”。 
Re

本报消息:freenxiaoyu称有些斑竹的安全意识连普通用户都不如 

针对近期bbs斑竹jjason连续发生因为灌水,言语粗鲁导致连续被封版面,直至 
发生被封全站的恶性事故。紫丁香关税安全部部长freexiaoyu怒斥jjason:“灌 
水安全意识甚至连普通用户都不如。”
Re

紫丁报消息:国际社会纷纷谴责派独言论。 

近日,紫丁香派独分子公然宣称“pielove版就是紫丁香的joke2”。针对这一言论 
joke版斑竹迅速发表声明称:“joke版坚持一个joke原则”“紫丁香只有一个joke” 
“joke版的主权和领土完整不容分割”。 

国际社会也迅速做出反应纷纷表示谴责,pielove版斑竹theend,副斑竹dogcat也再 
次重申了坚持“一个joke”政策。single, girl, man等版斑竹也纷纷表示“派独 
分子是国际社会的麻烦制造者”。 
Re

本报讯: single版不存在灌水行为。 

single版斑竹rainbai在接受本报记者专访时称:“single版从本质上说是属于紫丁香的, 
属于所有站友的。single上水多就是对紫丁香,对站友利益的体现。我任为single版不存 
在灌水行为”
Re

另讯:黑土地是最自由民主的版面 

黑土地版斑竹spacefight近日对媒体表示,黑土地是最自由民主的版面。针对pielove版 
不断攻击黑土地版“封人过多,删贴严重,压制言论自由”,spacefight称:“鹊桥版 
版主在民主问题上双重标准,除暴干涉别版内政;近日又爆出采用黑名单制度虐囚丑闻” 
。“人权问题首先是生存权问题”。spacefight称“黑土地的民主状况是最好的,其他 
版面都不怎么样。”
Re: popstar: 关闭bbs是为了刷水箱 

《狗城晚报》的评论说,似乎没有(紫丁香)网民愿意相信官方公布的关站原因。“如果 
网民对站方的权威产生怀疑,无疑将对事件的后续处理带来极大的隐患。”  

《西方早报》的评论说:“我们的关注更在于对一套基本的公共危机应急机制的关注。但 
现在看来,除了我们一再强调的信息公开、网民理性之外,在站方的基本应急协调机制方 
面,我们的准备也还很不充分。”  

《北方日报》的评论说:“毫无疑问,突发事件考验着站方管理公共事务的能力。经历了 
前年的非典(萨斯)之后,网民对‘谣言止于公开’可谓完全达成了共识。”  
posted @ 2006-01-05 20:45 罗明 阅读(551) | 评论 (0)编辑 收藏
 
转自:http://blog.csdn.net/3cts/archive/2005/12/30/566079.aspx

  引言
  
  大家都知道可以通过post或者get获得form表单的数据,那么我们如何实现不刷新的提交直接获得页面上的数据呢?这就要借助xmlhttp协议了。xmlhttp是xmldom技术的一部分。
  
  下面的代码就是一个很简单的例子,我们利用xmlhttp技术实现简单的用户登陆。
  
  开始
  
  1.简单的登录页面
  
  login.jsp
  function toServer(){
  var xml = "<root>"+
  "<name>"+document.all('name').value+"</name>"+
  "<pwd>"+document.all('pwd').value+"</pwd>"+
  "</root>";
  
  var XMLSender = new ActiveXObject("Microsoft.XMLHTTP" );
  XMLSender.Open("POST",'do_login.jsp',false);
  XMLSender.send((xml));
  alert(XMLSender.responseText); //可处理后台返回的结果
  }
  
  姓名:<input type="text" id="name" /><br>
  密码:<input type="text" id="pwd" /><br>
  <input type="button" value="登录" onclick="toServer()">
  
  2.后台的登录处理页面
  do_login.jsp
  
  <%
  //读取XMLHTTP流
  java.io.BufferedReader br = request.getReader();
  String str = "";
  while (str != null) {
  str = br.readLine();
  process (str); //可通过任何语言实现解析XML,进行业务处理
  }
  
  //返回信息
  javax.servlet.ServletOutputStream sos = response.getOutputStream();
  sos.print("login success" );
  sos.close();
  %>
  与传统的“提交-回发-重绘”式的web系统基本运行结构不同,我们可以通过通过XMLHTTP实现无刷新的客户端直接与服务器交互,极大的提高用户的感受度。
  
  查考资料
  
  XMLHTTP方法:
  
  Open bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword
  bstrMethod:数据传送方式,即GET或POST。
  bstrUrl:服务网页的URL。
  varAsync:是否同步执行。缺省为True,即同步执行,但只能在DOM中实施同步执行。
  应用中一般将其置为False,即异步执行。
  bstrUser:用户名,可省略。
  bstrPassword:用户口令,可省略。
  
  Send varBody
  varBody:指令集。可以是XML格式数据,也可以是字符串,流,或者一个无符号整数数组。也可以省略,让指令通过Open方法的URL参数代入。
  
  setRequestHeader bstrHeader, bstrValue
  bstrHeader:HTTP 头(header)
  bstrValue:HTTP 头(header)的值
  如果Open方法定义为POST,可以定义表单方式上传:
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  
  XMLHTTP属性:
  
  onreadystatechange:在同步执行方式下获得返回结果的事件句柄。只能在DOM中调用。
  responseBody:结果返回为无符号整数数组。
  responseStream:结果返回为IStream流。
  responseText :结果返回为字符串。
  responseXML:结果返回为XML格式数据。
posted @ 2006-01-03 18:59 罗明 阅读(449) | 评论 (0)编辑 收藏
 

  • Content with Style: Fixing the Back Button and Enabling Bookmarking for AJAX Apps - Mike Stenhouse explains how to fix two of the more distracting problems with Ajax. These can be particularly problematic for users new to Ajax applications.  Since Ajax apps typically load into a single web page, it makes pressing the Back button meaningless or actually harmful.  And this breaks the browser usage model annoyingly.  Also, individual views of data in an Ajax application cannot have a URL or permalinks unless precautions are taken.  Mike does a great job covering how to reduce these problems.
  • Saving Session Across Page Loads Without Cookies, On The Client Side - Ajax virtuoso Brad Neuberg strikes again with a detailed explanation of how to deal with saving session information across page loads without relying on cookies.  This is important in larger applications which typically want to store more information than a cookie can hold.  Brad also has some terrific tools to deal with this as well (see AMASS below)
  • Call SOAP Web services with AJAX - By design, Ajax is a voracious consumer of web services like XML/HTTP, REST, and SOAP.  A great article at IBM's DeveloperWorks describes how to easily call SOAP web services from Ajax.  This is important because SOAP is a complex protocol that requires some familiarity to use.  While Ajax development tools like Atlas, General Interface, and Bindows will solve this by providing a SOAP stack, for many, hand development of back-end SOAP request is the only option right now to achieve interoperability with WS-I Basic Profile web services.
  • Ajax using only an image - Browsers and networks continue to get more secure and many configurations will not allow an Ajax application to use web services, and almost none of them will allow you to access a server other than the one the Ajax app loaded from.  Enter an elegant technique to solve this by using image URLs.  Not for the faint of heart, and certainly a possible security hole but a compelling solution nonetheless.

Ajax Tools and Libraries


  • TIBCO's General Interface - I've not used this Ajax development environment extensively yet but it apparently eats its own dog food and runs entirely inside a browser (which apparently must be Internet Explorer).  Supposedly containing an entire SOAP stack, a full-blown IDE, and numerous libraries, General Interface is one of the leading solutions in this space and can be downloaded and used today.  TIBCO cautions you not to use it for production apps yet, but my initial use was encouraging.
  • Microsoft Atlas - A serious contender in the Ajax IDE space (details here), Microsoft is planning for Atlas to be a heavy-duty, enterprise scale Ajax solution.  Integrated into Visual Studio 2005, Atlas is just a code name but expect that it will be a leading Ajax player from the get go and will live up to its name.
  • Dojo - Still in early release, the open source Ajax library, Dojo, is getting lots of attention from folks in the know.  Dojo is billed as a "powerful, portable, lightweight, and tested tools for constructing dynamic interfaces. Dojo lets you prototype interactive widgets quickly, animate transitions, and build Ajax requests with the most powerful and easiest to use abstractions available."  I haven't used it yet, but you can bet I will be soon.
  • Script.aculo.us - One of the very best Ajax visual effects libraries that I've used is the eponymous script.aculo.us.  Advertised as "Web 2.0 JavaScript", script.aculo.us has numerous effects and convenience tools, all built on nice, tight object-oriented abstractions.  I've used it and I can recommend it for its simplicity and reliability.
  • Bindows - Mind-blowing Ajax library for recreating the full richness of native applications, and includes a SOAP stack.
  • AMASS - Ajax gets good client-side storage.  A brilliant piece of work by Brad Neuberg, check out a description of how AMASS works here.
  • TrimQuery - A robust JavaScript database for Ajax.  When combined with AMASS above, neat things can really happen.

    Ruby on Rails


  • Ruby on Rails - Should probably be listed first, not down here.  The best lightweight, server-side Ajax framework out there today.  Note that Ajax pioneers and Web 2.0 leaders 37Signals sponsor this site and RoR is used by a great many successful Web 2.0 sites.

  • Log4Ajax - Many serious developers wouldn't switch to a new programming model without a Log4J equivalent and here it is.  Both traditional console as well as advanced logging support for Ajax is here today.  SourceForge site here.
  • Backbase - This IDE is getting good reviews but it apparently uses an abstraction layer like Morfik.  I haven't used it yet but I keep hearing about it.
  • Sajax - A good competent server-side framework featuring support for most common back-end languages like Perl, Python, Ruby and much more.

Note: The most complete Ajax framework listing I've seen available is here.

Ajax News and Resources

Ajax Developer's Journal

  • The Ajax Developer's Journal - Good sources of news for Ajax are still pretty scarce but that's starting to change in a big way.  SYS-CON has recently launched their Ajax Developer's Journal and has been working closely with Jesse James Garrett, who coined the term.  Expect lots of interesting and topical new articles and coverage on a regular basis.
  • Ajaxian - Dion Almaer and Ben Galbraith have been working on Ajaxian for a while now and it remains one of the very best sources for the latest Ajax news, tools, events, and general inspiration.

Critiques and Analysis of Ajax


  • Ajax Mistakes - This is Alex Bosworth's terrific analysis of the early problems with Ajax.  He a big believer in the technology and his Ajax-powered LiveMarks site is one of my absolute favorites.  A good place to start to understand some of the challenges with Ajax.
  • Fixing Ajax: XmlHttpRequest Considered Harmful - Some good coverage of why Ajax doesn't really enable the use of the services of other web sites without a lot of work.  This is a big barrier to leveraging Web 2.0's global services landscape.  This can be solved a number of ways however and the options are explored here.  The image URL solution a few paragraphs above is missing but otherwise this is an excellent summary.

    Ajax Network Constraints


  • 10 Places You Must Use Ajax - Alex is back and carefully enumerates the good places to use Ajax.  He also covers when to avoid it.  Excellent material for those learning how to design with Ajax.
  • Top 10 Reasons Ajax Is Here To Stay - Andre Charland nails it.  Though some folks dislike Ajax for a variety of reasons, here are some terrific positive motivations for using it today.

And don't forget to see what can be done with Ajax!  Check out these great new Ajax-enabled applications here.

posted Friday, 30 December 2005

posted @ 2006-01-03 11:42 罗明 阅读(481) | 评论 (0)编辑 收藏
 
这几天一直在写代码,struts架构 + jsp + javascript,都抽不出时间写Blog了。可能生活过得充实就很少会写Blog吧。能做自己喜欢的事,还能填满腰包,这估计就是最幸福的工作吧!要继续调试我的javascript了,学习ing
posted @ 2005-12-28 22:09 罗明 阅读(83) | 评论 (0)编辑 收藏
 
这几天一直在写代码,struts架构 + jsp + javascript,都抽不出时间写Blog了。可能生活过得充实就很少会写Blog吧。能做自己喜欢的事,还能填满腰包,这估计就是最幸福的工作吧!要继续调试我的javascript了,学习ing
posted @ 2005-12-28 14:10 罗明 阅读(130) | 评论 (0)编辑 收藏
 
第一个是XmallCharter, 何为Charter? 就是画图表的啦。Xmall吗?是我毕业后要开的公司的名字啊(这家伙又在yy了^_^)。

XmallCharter是一个基于JFreeChart库的图表软件,仿照PowerPoint里的图表功能,支持饼状图、域图、线状图、条形图、3D条形图等图表类型,100% Java Swing 代码,绿色软件,解压缩即可在Linux、W$等系统上运行。

项目现在“寄居”在SourceForge.net上,最新版本是0.2。

去年学校的创新竞赛(也是挑战杯的校内选拔赛),每个俱乐部都要交作品,我顺便把XmallCharter和文档交了上去,还好,得了个三等奖,当时还比较兴奋(这个项目本来是《界面设计》课程的大作业,那时候刚刚完成,才花了一个星期,意外之喜)

项目网址:www.sourceforge.net/projects/xmallcharter

xmall.jpg


第二个是XBlogger,一个基于Eclipse RCP的Blog客户端,是今年IBM校园科技创新竞赛的参赛作品,但是由于某些原因,最终没能提交(55~,早点回学校就好了)。本地数据库使用HSqlDB,目前只支持Blogger.com(.Text类型的也能支持,但还没加上,懒了)。本来应该有个Web Service中间层,以后可行的话可能会加上,基本架构和截屏如下(现在还没开源,完善一下先):

基本架构:

xmall_arch.gif

(用OpenOffice打开的Word文档,有点变形)

截图:

Xblogger.JPG
posted @ 2005-12-16 21:06 罗明 阅读(4651) | 评论 (4)编辑 收藏
 

构建J2ME游戏:用TiledLayer构造背景

在这一节中,我们要使用TiledLayer类为游戏添加一个背景。游戏界面分为三个区域:顶部表示天空,couple小精灵所在的中部是地面,底部是大海。每个区域分别使用一个32*32像素的不同颜色图片进行填充,填充的工作由TiledLayer类完成。

首先将屏幕分成32*32的小方格,行和列的索引都从0开始,如图4。

j2me3_figure4.gif

           图 4. 均匀分割屏幕

(0,0)到(1,4)的方格表示天空,(2,0)到(2,4)表示地面,(3,0)到(4,4)表示海面。我们用图5中的图片填充对应方格。

tiledlayer1.gif

图 5. 背景图片

背景图片的第一部分(32*32)表示地面,第二部分表示大海,第三部分表示天空。使用TiledLayer时,图片的索引是从1开始的(不是0,所以地面图像的位置是1,大海是2,天空是3)。TiledLayer类可以将图5分割成三张图片,然后用每张图片填充对应的方格。在这里,我们用三个 32*32大小图片填充5行5列的背景,部分代码如下:

// 加载图片
backgroundImg = Image.createImage("/tiledLayer1.gif");

// 创建TiledLayer背景
background = new TiledLayer(55, backgroundImg, 3232);


TiledLayer构造器的前两个参数表示背景大小,第三个是图像,最后两个是每个格子的长和宽。TiledLayer类将根据格子的大小切割图像,然后放到背景的对应方格中。

最后剩下的就是设置每个方格里放置的图像了。创建背景的所有代码都在createBackground()方法里,如下所示。在MyGameCanvas 类的start()里调用这个方法,然后在buildGameScreen()方法的最后添加background.paint(g),这使得 TiledLayer实例将自己绘制到屏幕上。

// 使用TiledLayer创建背景
private void createBackground() throws IOException
{
    
// 加载图片
    backgroundImg = Image.createImage("/tiledLayer1.gif");

    
// 创建tiledLayer背景
    background = new TiledLayer(55, backgroundImg, 3232);

    
// 布置图像的数组
    int[] cells = {
        
33333,  // 天空
        33333,  // 天空
        11111,  // 地面
        22222,  // 大海
        22222   // 大海
    };

    
// 设置背景
    for(int i = 0; i < cells.length; i++)
    {
        
int column = i % 5;
        
int row = (i - column) / 5;
        background.setCell(column, row, cells[i]);
    }

    
// 设置背景位置
    background.setPosition(GAME_ORIGIN_X, GAME_ORIGIN_Y);
}


最终效果如图6。

j2me3_figure6.gif

    图 6. 添加了背景的游戏截屏

原文见:http://today.java.net/pub/a/today/2005/07/07/j2me3.html?page=4
posted @ 2005-12-16 19:58 罗明 阅读(1090) | 评论 (0)编辑 收藏
 
...
在奔波中我慕然回首 看看過去的年頭
曾經努力得到的所有 轉眼之間不停留
但你卻永遠在我的背後 承受壓力與憂愁
縱然是汗在流 嚐盡苦頭 還是陪我往前走

脆弱是令人容易跌倒 泛起失望的念頭
有誰甘心向現實低頭 還是無奈的接受
人總會有想哭的時候 你總會用你的雙手
悄悄的撫平了我的傷口 不會讓別人知道

你是我的溫柔 給我所有 代替了一切哀愁
不管天有多長 地有多久 無悔的為我守候

你是我的港口 讓我停留 停留在你的溫柔
縱使天也會荒 地也會老 愛是沒有盡頭
posted @ 2005-12-14 18:13 罗明 阅读(50) | 评论 (0)编辑 收藏
 
http://www.frappr.com/linux

if you are using Linux, pls add yourself to this list on above site.

Screenshot-4.gif
posted @ 2005-12-14 11:07 罗明 阅读(361) | 评论 (0)编辑 收藏
 
没想到这么容易,打开TSC, 默认选择RDP方式(另外两种RDPv5、VNC还没试过呢,待会试试,看效果怎样),填一些基本信息(我就填了ip地址、工作组名和计算机名),选择“Connect”连接,就弹出了熟悉的Windows登录框,下面是一个截屏:

Screenshot-3.gif
posted @ 2005-12-13 10:22 罗明 阅读(2979) | 评论 (7)编辑 收藏
仅列出标题
共14页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last