URL分別用三個List保存,
一個是boring,這個list中的url最后來下載
其他兩個是interesting和average
當搜索到url時檢查是否包含設定為boring的詞,并放入boring中
用戶可設定“深度搜索”:每搜到一個url就放在list的最前面
也可廣度
有些網(wǎng)頁鏈接要特殊處理:
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...");
當下載第一個URL時(一般是網(wǎng)站主頁),如果等待時間過長,那么其他線程要么會認為網(wǎng)站已下載完而結(jié)束,要么會在下面標*代碼處拋出
NullPointerException, 很少能夠存活下來。
else if(queueSize() == 0) /* queueSize()已經(jīng)被同步 */
{
break;
}
URLToDownload nextURL;
synchronized(queue)
{
nextURL = queue.getNextInQueue();
downloadsInProgress++;
}
synchronized(urlsDownloading)
{
urlsDownloading.add(nextURL);
}
int newDepth = nextURL.getDepth() + 1; **********************
估計可能是線程交叉了,還沒來得及同步就跑到后面去執(zhí)行g(shù)etDepth()了。
在
nextURL = queue.getNextInQueue();后面加上判斷就OK了:
synchronized(queue)
{
nextURL = queue.getNextInQueue();
if(nextURL == null)
{
continue;
}
downloadsInProgress++;
}
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.
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:
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.
- Download the Eclipse Platform Runtime Binary driver from www.eclipse.org.
- 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:
- 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.
- 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" };
- In your application, create an instance of the Help class by passing the options.
Infocenter infocenter = new Help(options);
- To start the help system:
helpSystem.start();
-
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.
Class.forName is excellent
例:
Class.forName("weblech.util.Log4j");
在Log4j里定義一個靜態(tài)類構(gòu)造器,里面放apache log4j的初始代碼。
其他如注冊數(shù)據(jù)源、界面本地化。。。
Eclipse看代碼是最爽的:
查看類的引用、代碼導航
調(diào)試網(wǎng)頁時出錯,無意中發(fā)現(xiàn)出錯頁的源文件中有這樣一段注釋:
<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服務器的網(wǎng)站,都不會出現(xiàn)M$的惱人友好信息了。
以前一直沒找到這個選項,以為不可以呢。終于發(fā)現(xiàn)工具菜單-->選項里的“播放機設置”欄的第一個復選框就是設置將播放器置于最前端。寫出來怕大家有需要的^_^
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?
Jan. 7, 2006 02:30 PM
Source:
Nine Tips for Designing Rich Internet Applications *****************************************************************
Recently I was asked to provide input into a presentation. The question was asked, if you were going to provide some quick basic guidelines for designing rich applications what would they be.
Here were the nine thoughts as they originally came to my head.
1)
Make it directly interactiveInstead of page to page interactions think direct interaction. Use in context editing as much as possible. Use drag and drop only where it makes sense. Barring a selection model, put tools as close to the objects being edited as possible. Cooper states it as "Where there is output, let there be input."
2)
Make it invitingUse hover to invite users to the next level of interaction. If the interface responds well to light events (like hover) it can be used to entice the user to interact.
3)
Use lightweight, in-context popups instead of page transitions where possibleAlthough they will eventually get over-used, lightweight popups can be your friend. Think of them as annexed areas for your page.
4)
Use real-estate creativelyAs mentioned popups help. But slide outs have long been allies in desktop tools, they can be an aid in the world of the web.
5)
Cross page boundaries reluctantlyThink of a page switch as a context boundary that the user may or may not want to cross. Think of it as a place that many of your users will lose interest and no longer follow you.
6)
Create a light footprintMake it extremely easy to interact. Rating movies or news with just a click on a star with no-refresh is awesome. Checking hostnames without leaving the page is an excellent way to keep a user engaged. Shopping by clicks that only add to a container on the page (instead of going to a new page) are like impulse aisles in the grocery store.
7)
Think of your interactions as storyboardsAs the designer you are the director. Think about the event states as acts in a play and your interface elements as actors. Get them all moving towards telling your story. Putting the frames down on a storyboard is a great way to rehearse your script. Think of the interesting moments as opportunities for engagement.
8)
Communicate transitionsKeeping the user informed during lightweight operations (that don't leave the page) with spinning wheels, busy or progress indicators keep the user engaged with a living page.
9)
Think in objectsInstead of thinking about content and pages, think about Rich Internet Objects. The travel log in Yahoo!'s Trip Planner is a good example. Once created it can be searched for or shared. This will help you create more interactive applications and make the user's work recognizable and sharable.
These are not exhaustive. Even as I go to publish this I can think of other tips to include... but I will resist adding to the list. Perhaps you have some tips/principles that have helped you solve design challenges?
源多說明通過你的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
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 {
Item(int value) {
this.value = value;
}
public int getValue() {
return value;
}
final void addListener(Listener l) {
}
}
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 {
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";
}
public abstract Item newItem(int value);
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();
}
}
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);
[新華社]singlerly被雙規(guī)

1月3日Man版消息。北京時間14點左右Man版?zhèn)鞒鱿?,來自紫丁香的singlerly日前在
Man版被雙規(guī)。
當?shù)毓賳T發(fā)言指出,該嫌疑犯是因為煽動灌水而于當天14點左右被捕的。目前正于押解
前往xiaoheiwu的途中。
據(jù)當?shù)厝罕姺Q,當?shù)卣臋?quán)力混亂局面是singlerly同志遭到雙規(guī)的主要原因。很多群眾對singlerly的雙重不幸報以同情和羨慕。
另有一位不愿透露姓名的權(quán)威人士指出,造成這種混亂局面的原因是由于相親的處理問題,現(xiàn)在值班站務jimu小同學已基本控制了換亂的局面。
新華社駐Man版記者cc現(xiàn)場為您報道。

Re

感謝前方記者為我們帶來的現(xiàn)場報道

現(xiàn)在是廣告時間
廣告過后請繼續(xù)關(guān)注
Re

下面繼續(xù)播報最新新聞:

丁香社哈爾濱1月3日電(記者八卦王子)

談天聊地實習片長jimu日前表示,目前8區(qū)關(guān)稅人員關(guān)系總體穩(wěn)定,但斑竹和水友
和諧制度落實不到位、斑竹增長和調(diào)控機制不健全、侵害灌水者合法權(quán)益等問題
仍然比較突出。


jimu表明在第十一個五年規(guī)劃里借助改革深入攻堅戰(zhàn),要基本解決斑竹缺額問題。

他進一步提出,要針對當前的突出矛盾,以建立和諧穩(wěn)定的灌水關(guān)系為主線,以
維護最廣大的關(guān)稅者合法權(quán)益為重點,積極探索、創(chuàng)新校內(nèi)BBS先進平臺條件下和
諧灌水關(guān)系和管理版面體制和機制。
Re

本報訊 斑竹多id灌水是為了反恐

1月4日 紫丁香站長lanslot在聽證會上被問及:每個斑竹允許同時登陸3個帳號,免費獲取
上站時間和文章數(shù),這是為了減輕紫丁香系統(tǒng)負擔么?
lanslot說:“眾所周知,目前國際恐怖勢力猖獗,bbs又是恐怖分子的重點襲擊對象,所
以必須加強bbs反恐力度,bbs斑竹義不容辭地擔負起bbs義務安全員的重要職責?!?/SPAN>
Re

bbs 八卦報消息:關(guān)閉bbs是為了刷水箱

5月5日 紫丁香全面關(guān)閉,據(jù)紫丁香總管popstar稱:由于戰(zhàn)友灌水過多,導致紫丁香系統(tǒng)
水垢嚴重,暫時關(guān)閉紫丁香3天,清除水垢。具體放水時間另行通知。

另有消息說,本次關(guān)站與紫丁香上游水母廠爆炸有關(guān)。水母廠技術(shù)站長接受本報記者采訪
時稱:“爆炸只產(chǎn)生了二氧化碳和水”。

Re

本報消息:freenxiaoyu稱有些斑竹的安全意識連普通用戶都不如

針對近期bbs斑竹jjason連續(xù)發(fā)生因為灌水,言語粗魯導致連續(xù)被封版面,直至
發(fā)生被封全站的惡性事故。紫丁香關(guān)稅安全部部長freexiaoyu怒斥jjason:“灌
水安全意識甚至連普通用戶都不如?!?/SPAN>
Re

紫丁報消息:國際社會紛紛譴責派獨言論。

近日,紫丁香派獨分子公然宣稱“pielove版就是紫丁香的joke2”。針對這一言論
joke版斑竹迅速發(fā)表聲明稱:“joke版堅持一個joke原則”“紫丁香只有一個joke”
“joke版的主權(quán)和領土完整不容分割”。

國際社會也迅速做出反應紛紛表示譴責,pielove版斑竹theend,副斑竹dogcat也再
次重申了堅持“一個joke”政策。single, girl, man等版斑竹也紛紛表示“派獨
分子是國際社會的麻煩制造者”。

Re

本報訊: single版不存在灌水行為。

single版斑竹rainbai在接受本報記者專訪時稱:“single版從本質(zhì)上說是屬于紫丁香的,
屬于所有站友的。single上水多就是對紫丁香,對站友利益的體現(xiàn)。我任為single版不存
在灌水行為”
Re

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

黑土地版斑竹spacefight近日對媒體表示,黑土地是最自由民主的版面。針對pielove版
不斷攻擊黑土地版“封人過多,刪貼嚴重,壓制言論自由”,spacefight稱:“鵲橋版
版主在民主問題上雙重標準,除暴干涉別版內(nèi)政;近日又爆出采用黑名單制度虐囚丑聞”
?!叭藱?quán)問題首先是生存權(quán)問題”。spacefight稱“黑土地的民主狀況是最好的,其他
版面都不怎么樣?!?/SPAN>
Re: popstar: 關(guān)閉bbs是為了刷水箱

《狗城晚報》的評論說,似乎沒有(紫丁香)網(wǎng)民愿意相信官方公布的關(guān)站原因?!叭绻?nbsp;
網(wǎng)民對站方的權(quán)威產(chǎn)生懷疑,無疑將對事件的后續(xù)處理帶來極大的隱患?!?nbsp;

《西方早報》的評論說:“我們的關(guān)注更在于對一套基本的公共危機應急機制的關(guān)注。但
現(xiàn)在看來,除了我們一再強調(diào)的信息公開、網(wǎng)民理性之外,在站方的基本應急協(xié)調(diào)機制方
面,我們的準備也還很不充分?!?nbsp;

《北方日報》的評論說:“毫無疑問,突發(fā)事件考驗著站方管理公共事務的能力。經(jīng)歷了
前年的非典(薩斯)之后,網(wǎng)民對‘謠言止于公開’可謂完全達成了共識?!?nbsp;
轉(zhuǎn)自:http://blog.csdn.net/3cts/archive/2005/12/30/566079.aspx
引言 大家都知道可以通過post或者get獲得form表單的數(shù)據(jù),那么我們?nèi)绾螌崿F(xiàn)不刷新的提交直接獲得頁面上的數(shù)據(jù)呢?這就要借助xmlhttp協(xié)議了。xmlhttp是xmldom技術(shù)的一部分。 下面的代碼就是一個很簡單的例子,我們利用xmlhttp技術(shù)實現(xiàn)簡單的用戶登陸。 開始 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); //可處理后臺返回的結(jié)果 } 姓名:<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); //可通過任何語言實現(xiàn)解析XML,進行業(yè)務處理 } //返回信息 javax.servlet.ServletOutputStream sos = response.getOutputStream(); sos.print("login success" ); sos.close(); %> 與傳統(tǒng)的“提交-回發(fā)-重繪”式的web系統(tǒng)基本運行結(jié)構(gòu)不同,我們可以通過通過XMLHTTP實現(xiàn)無刷新的客戶端直接與服務器交互,極大的提高用戶的感受度。 查考資料 XMLHTTP方法: Open bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword bstrMethod:數(shù)據(jù)傳送方式,即GET或POST。 bstrUrl:服務網(wǎng)頁的URL。 varAsync:是否同步執(zhí)行。缺省為True,即同步執(zhí)行,但只能在DOM中實施同步執(zhí)行。 應用中一般將其置為False,即異步執(zhí)行。 bstrUser:用戶名,可省略。 bstrPassword:用戶口令,可省略。 Send varBody varBody:指令集??梢允荴ML格式數(shù)據(jù),也可以是字符串,流,或者一個無符號整數(shù)數(shù)組。也可以省略,讓指令通過Open方法的URL參數(shù)代入。 setRequestHeader bstrHeader, bstrValue bstrHeader:HTTP 頭(header) bstrValue:HTTP 頭(header)的值 如果Open方法定義為POST,可以定義表單方式上傳: xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" XMLHTTP屬性: onreadystatechange:在同步執(zhí)行方式下獲得返回結(jié)果的事件句柄。只能在DOM中調(diào)用。 responseBody:結(jié)果返回為無符號整數(shù)數(shù)組。 responseStream:結(jié)果返回為IStream流。 responseText :結(jié)果返回為字符串。 responseXML:結(jié)果返回為XML格式數(shù)據(jù)。 |
Dec. 31, 2005 01:30 AM
http://au.sys-con.com/read/166995.htmAjax has been the
other big software story of 2005, along with
Web 2.0. An optional ingredient to Web 2.0 software, Ajax has changed the perception of Web-based software as being horribly clunky, page-oriented, and boring when compared to native computer applications. Ajax describes a set of techniques that makes Web software quite the opposite. A quick visit to Google Maps and its live scrollable map tiles or NetVibes and its drag-and-drop reorganization of your personal data both show how potent and compelling Ajax techniques really are.
I originally covered the current state of Ajax back in August in a widely linked article. It still provides a good summary of the history, benefits, and pitfalls of Ajax but it's amazing what has happened since then. It's also interesting to see what issue haven't been resolved. Though Ajax isn't a technology, it's strictly constrained by the technologies that it uses to describe how to weave visually arresting, highly intereactive, web service-based applications that can be loaded into any browser with a single URL, all without installing any software. But some challenges continue to remain but are decreasing in concern.
The term and world-wide attention behind Ajax is not even a year old, but you can find a wide range of poweful tools either with newly added support for Ajax or created just to support the Ajax way of life. In addition, many of the constaints and problems with Ajax have been resolved or greatly reduced. But keeping track of all these developments is very difficult, so I've compiled a summary here of the major advances in Ajax so far this year.
I hope you enjoy. And as always, please add your own at the bottom for all to benefit...
Improved Ajax Techniques
- 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
- - 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 - 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

- 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.
- 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
這幾天一直在寫代碼,struts架構(gòu) + jsp + javascript,都抽不出時間寫B(tài)log了。可能生活過得充實就很少會寫B(tài)log吧。能做自己喜歡的事,還能填滿腰包,這估計就是最幸福的工作吧!要繼續(xù)調(diào)試我的javascript了,學習ing
第一個是XmallCharter, 何為Charter? 就是畫圖表的啦。Xmall嗎?是我畢業(yè)后要開的公司的名字?。ㄟ@家伙又在yy了^_^)。
XmallCharter是一個基于JFreeChart庫的圖表軟件,仿照PowerPoint里的圖表功能,支持餅狀圖、域圖、線狀圖、條形圖、3D條形圖等圖表類型,100% Java Swing 代碼,綠色軟件,解壓縮即可在Linux、W$等系統(tǒng)上運行。
去年學校的創(chuàng)新競賽(也是挑戰(zhàn)杯的校內(nèi)選拔賽),每個俱樂部都要交作品,我順便把XmallCharter和文檔交了上去,還好,得了個三等獎,當時還比較興奮(這個項目本來是《界面設計》課程的大作業(yè),那時候剛剛完成,才花了一個星期,意外之喜)
第二個是XBlogger,一個基于Eclipse RCP的Blog客戶端,是今年IBM校園科技創(chuàng)新競賽的參賽作品,但是由于某些原因,最終沒能提交(55~,早點回學校就好了)。本地數(shù)據(jù)庫使用
,目前只支持Blogger.com(.Text類型的也能支持,但還沒加上,懶了)。本來應該有個Web Service中間層,以后可行的話可能會加上,基本架構(gòu)和截屏如下(現(xiàn)在還沒開源,完善一下先):
在這一節(jié)中,我們要使用TiledLayer類為游戲添加一個背景。游戲界面分為三個區(qū)域:頂部表示天空,couple小精靈所在的中部是地面,底部是大海。每個區(qū)域分別使用一個32*32像素的不同顏色圖片進行填充,填充的工作由TiledLayer類完成。
?????????? 圖 4. 均勻分割屏幕
圖 5. 背景圖片
背景圖片的第一部分(32*32)表示地面,第二部分表示大海,第三部分表示天空。使用TiledLayer時,圖片的索引是從1開始的(不是0,所以地面圖像的位置是1,大海是2,天空是3)。TiledLayer類可以將圖5分割成三張圖片,然后用每張圖片填充對應的方格。在這里,我們用三個 32*32大小圖片填充5行5列的背景,部分代碼如下:
TiledLayer構(gòu)造器的前兩個參數(shù)表示背景大小,第三個是圖像,最后兩個是每個格子的長和寬。TiledLayer類將根據(jù)格子的大小切割圖像,然后放到背景的對應方格中。
最后剩下的就是設置每個方格里放置的圖像了。創(chuàng)建背景的所有代碼都在createBackground()方法里,如下所示。在MyGameCanvas 類的start()里調(diào)用這個方法,然后在buildGameScreen()方法的最后添加background.paint(g),這使得 TiledLayer實例將自己繪制到屏幕上。
??? 圖 6. 添加了背景的游戲截屏