﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-zhyiwww</title><link>http://www.blogjava.net/zhyiwww/</link><description>用平实的笔触，记录曾经在编程路上的点点滴滴………</description><language>zh-cn</language><lastBuildDate>Mon, 13 Oct 2008 11:48:17 GMT</lastBuildDate><pubDate>Mon, 13 Oct 2008 11:48:17 GMT</pubDate><ttl>60</ttl><item><title>OpayLayers</title><link>http://www.blogjava.net/zhyiwww/archive/2008/10/13/234009.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 13 Oct 2008 06:50:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/10/13/234009.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/234009.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/10/13/234009.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/234009.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/234009.html</trackback:ping><description><![CDATA[OpenLayers.Contral<br /><pre id="line1"> map.addControl(new OpenLayers.Control.PanZoomBar());<br /><img height="384" alt="panzoombar.PNG" src="http://www.blogjava.net/images/blogjava_net/zhyiwww/OpenLayers/panzoombar.PNG" width="505" border="0" /><br /><br />map.addControl(new OpenLayers.Control.MouseToolbar());<br /><br /><br /><img height="402" alt="mousetoolbar.PNG" src="http://www.blogjava.net/images/blogjava_net/zhyiwww/OpenLayers/mousetoolbar.PNG" width="510" border="0" /><br /><br />map.addControl(new OpenLayers.Control.LayerSwitcher());<br /><img height="280" alt="layerswitcher.PNG" src="http://www.blogjava.net/images/blogjava_net/zhyiwww/OpenLayers/layerswitcher.PNG" width="798" border="0" /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></pre><img src ="http://www.blogjava.net/zhyiwww/aggbug/234009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-10-13 14:50 <a href="http://www.blogjava.net/zhyiwww/archive/2008/10/13/234009.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>grep的非贪婪模式</title><link>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231281.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Fri, 26 Sep 2008 05:25:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231281.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/231281.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231281.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/231281.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/231281.html</trackback:ping><description><![CDATA[
		<p>最近在项目中，我希望能通过grep实现从一个html页面中检索出所有的超链接，<br />比如下面的一段代码</p>
		<p>&lt;tr class=rb&gt;&lt;td class=pl&gt;&lt;a href=mail.htm&gt;邮 箱&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=http://mail.163.com/&gt;163邮箱&lt;/a&gt;<br />&lt;a href="<a href="http://cn.mail.yahoo.com/?id=40014">http://cn.mail.yahoo.com/?id=40014</a>" class="greenfont"&gt;雅虎邮箱&lt;/a&gt;&lt;a href=http://www.126.com/&gt;126邮箱&lt;/a&gt;<br /> 　　&lt;a href=http://mail.sina.com.cn/&gt;新浪邮箱&lt;/a&gt; 　　&lt;a href=http://mail.qq.com/&gt;QQ邮箱&lt;/a&gt; 　　&lt;a href=http://www.hotmail.com/&gt;Hotmail&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=mail.htm&gt;更多&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;</p>
		<p>&lt;tr class=ry&gt;&lt;td class=pl&gt;&lt;a href=wangmei.htm&gt;视 频&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=http://www.youku.com/&gt;优酷网&lt;/a&gt;　　&lt;a href="<a href="http://www.tudou.com/">http://www.tudou.com/</a>"&gt;土豆网&lt;/a&gt;　　&lt;a href="<a href="http://www.ku6.com/">http://www.ku6.com/</a>"&gt;酷6网&lt;/a&gt;　　&lt;a href=http://6.cn/&gt;六间房&lt;/a&gt;　　&lt;a href=http://www.openv.com/&gt;OpenV天线&lt;/a&gt;　　&lt;a href=http://www.joy.cn/&gt;激动网&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=wangmei.htm&gt;更多&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;</p>
		<p>我希望能一次检索出所有的&lt;a href=http:.*/&gt;的信息, 我用的命令如下<br />C:\tmp&gt;grep -ior "href=.*\/&gt;" a.txt（回车） <br />结果如下：<br />&lt;tr class=rb&gt;&lt;td class=pl&gt;&lt;a href=mail.htm&gt;邮 箱&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=http://mail.163.com/&gt;163邮箱&lt;/a&gt; 　　&lt;a href="<a href="http://cn.mail.yahoo.com/?id=40014">http://cn.mail.yahoo.com/?id=40014</a>" class="greenfont"&gt;雅虎邮箱&lt;/a&gt; 　　&lt;a href=http://www.126.com/&gt;126邮箱&lt;/a&gt; 　　&lt;a href=http://mail.sina.com.cn/&gt;新浪邮箱&lt;/a&gt; 　　&lt;a href=http://mail.qq.com/&gt;QQ邮箱&lt;/a&gt; 　　&lt;a href=http://www.hotmail.com/&gt;Hotmail&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=mail.htm&gt;更多&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;</p>
		<p>因为这种模式是贪婪匹配模式。我希望能用非贪婪模式，来进行匹配，方法是通过在*修饰副后面添加\？,修改如下：</p>
		<p>C:\tmp&gt;grep -ior "href=.*\?\/&gt;" a.txt<br />结果如下：<br />href=mail.htm&gt;邮 箱&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=http://mail.163.com/&gt;163邮箱&lt;/a&gt; 　　&lt;a href="<a href="http://cn.mail.yahoo.com/?id=40014">http://cn.mail.yahoo.com/?id=40014</a><br />" class="greenfont"&gt;雅虎邮箱&lt;/a&gt; 　　&lt;a href=http://www.126.com/&gt;126邮箱&lt;/a&gt; 　　&lt;a href=http://mail.sina.com.cn/&gt;新浪邮<br />箱&lt;/a&gt; 　　&lt;a href=http://mail.qq.com/&gt;QQ邮箱&lt;/a&gt; 　　&lt;a href=http://www.hotmail.com/&gt;</p>
		<p>我期望的结果如下：</p>
		<p>href=mail.htm<br />href=http://mail.163.com/<br />href=<br />href=http://www.126.com/<br />href=http://mail.sina.com.cn/<br />href=http://mail.qq.com/<br />href=http://www.hotmail.com/<br />href=mail.htm<br />不知道如何实现。如果您有解决方案，请多多指导。先谢了。</p>
<img src ="http://www.blogjava.net/zhyiwww/aggbug/231281.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-09-26 13:25 <a href="http://www.blogjava.net/zhyiwww/archive/2008/09/26/231281.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DWR中使用回调函数的传值问题</title><link>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231268.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Fri, 26 Sep 2008 03:55:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231268.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/231268.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/09/26/231268.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/231268.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/231268.html</trackback:ping><description><![CDATA[
		<p>在使用DWR的时候，解决值得传递问题，可以通过回调函输实现对客户端的javascript的函数的调用。<br />同时可以通过DWR实现了通过javascript对java的调用。所以DWR解决了在Java和javascript之间的互相调用问题。<br /><br />但是在实际的调用过程中，有些问题还是需要解决的，如：<br /><br />如何在回调中传递串对象？<br />如何回调中传递Java对象？<br /><br />如果，能实现传递串对象，其实，已经可以实现了在javascript和java之间的数据传递，也可以通过在java上组合成json串返回，就可以实现，和对象的轻松转换。<br /><br />如果能实现传递对象，那不就省去了很多的问题，但是，这个问题，我也没有搞定。<br />不过象下面的例子，已经可以实现返回一个new Date()的Object对象了。不过，我看了一下，应该返回的是一个Date的串对象。<br /><br />如下代码，是在Dwr中的调用<br />javascript：<br />   ChatManager.regist(username,{<br />     callback:function(obj){<br />     alert("call back");<br />     alert("obj : " + obj);<br />     <br />     var map = getMap("theMap");<br />     alert(map.x);<br />        <br />   }});</p>
		<p>JAVA:</p>
		<p>   public Object regist(String username,HttpServletRequest request){<br />     <br />     System.out.println("regist user "+ username);<br />     <br />     updateUsersList(username,true,request);<br />     <br />     <br />     return new User("aaa","dsfdssdfdsf");<br />   <br />   }</p>
		<p>只有在此 regist方法有返回值得情况下，回调函数才能取到传入的值。<br />传递的如果是串类的对象，没有问题，如果我传递的是一个对象，就不能取到。<br />如<br />   <br />   public Object regist(String username,HttpServletRequest request){<br />     <br />     System.out.println("regist user "+ username);<br />     <br />     updateUsersList(username,true,request);<br />     <br />     <br />     return new A("myname");<br />   <br />   }<br />   注意：A是一个inner class,是在ChatManager里面定义的内部类。<br />   class A{<br />     private String uname;<br />     <br />     public A(String uname){<br />        this.uname = uname;<br />     }<br />     <br />     public String getUname(){<br />        return this.uname;<br />     }<br />   };<br />这种情况下，回调函输取得的就是null.</p>
		<p>   <br /></p>
<img src ="http://www.blogjava.net/zhyiwww/aggbug/231268.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-09-26 11:55 <a href="http://www.blogjava.net/zhyiwww/archive/2008/09/26/231268.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mysql+Hibernate+JSP中文乱码问题的解决</title><link>http://www.blogjava.net/zhyiwww/archive/2008/09/09/227986.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 09 Sep 2008 08:40:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/09/09/227986.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/227986.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/09/09/227986.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/227986.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/227986.html</trackback:ping><description><![CDATA[应该在以下几个地方检查：<br /><br />1：检查mysql安装目录下的配置文件my.ini,<br /><br />[mysql]<br />默认的default-character-set=latin1<br />改为default-character-set=utf8（不是utf-8）<br /><br />(注意，如果需要导数据，请先修改完编码，再进行数据导入，同时，注意你的源数据的格式，需要是utf8的编码）<br /><br />2：检查你的连接：<br />jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;amp;characterEncoding<b>=<font color="#008000" size="4">utf8</font></b>（不是utf-8）<br />连接数据库的编码也要设置为utf8<br /><br />3: 检查你的页面<br />&lt;%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%&gt;<br />设置文件的编码<br /><br />&lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;<br />设置内容编码<br /><br />如果这几个地方都统一了，应该就没有什么问题了。<br /><br />中文检索的实现：<br />在保证上面编码问题正确的情况下进行。<br /><br />首先，如果jsp页面到action,需要进行编码的转换<br />因为，jsp的页面form提交到action时，默认的是iso-8859-1的编码，需要转换成utf-8编码<br />代码如下：<br />String keyStr = request.getParameter("key");<br />        <br />        String pageStr = request.getParameter("page");<br />        String pageSizeStr = request.getParameter("pageSize");<br />        <br />        <br />        String key="";<br />        try {<br />            key = (keyStr==null?"":new String(keyStr.getBytes("iso-8859-1"),"utf-8"));<br />        } catch (UnsupportedEncodingException e2) {<br />            // TODO Auto-generated catch block<br />            e2.printStackTrace();<br />        }<br />        <br />这样，能保证，在jsp到action的编码不会出现乱码。<br />然后，在dao端，通过HQL进行中文模糊匹配检索，代码如下：<br />    public List findLikeKey(String key) {<br />        log.debug("finding all Pois instances");<br />        try {<br />            //'%"+key+"%'<br />            String queryString = "from Pois as poi where poi.poiname like <font color="#008000"><b><font size="5">'%"+key+"%'</font></b></font>";<br />            Query queryObject = getSession().createQuery(queryString);<br />            <br />//            queryObject.setString(0, "'%"+key+"'");<br />            <br />            log.info("query String is : "+queryObject.getQueryString());<br />            <br />            return queryObject.list();<br />        } catch (RuntimeException re) {<br />            log.error("find all failed", re);<br />            throw re;<br />        }<br />    }<br /><br />这样就可以实现检索的模糊匹配。<br />这样就OK了。<br /><br /><br /><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/227986.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-09-09 16:40 <a href="http://www.blogjava.net/zhyiwww/archive/2008/09/09/227986.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>清空div得好方法</title><link>http://www.blogjava.net/zhyiwww/archive/2008/09/06/227421.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Sat, 06 Sep 2008 11:30:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/09/06/227421.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/227421.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/09/06/227421.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/227421.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/227421.html</trackback:ping><description><![CDATA[本来需要清空一个div里面的子div,我本来的办法是取得其子元素，然后再遍历，然后再删除。<br />今天问了一下冬瓜，他告诉了一个好方法，嘿嘿，不错，拿来和大家共享。<br /><br />function clear(divObj){<br /><br />    divObj.innerHTML="";<br />    <br />}<br /><br />如上面的方法，直接把div的innerHTML置成""就可以了。有简单，有高效。<br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/227421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-09-06 19:30 <a href="http://www.blogjava.net/zhyiwww/archive/2008/09/06/227421.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>怎样使用sed删除文件中的换行符</title><link>http://www.blogjava.net/zhyiwww/archive/2008/09/03/226577.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Wed, 03 Sep 2008 02:12:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/09/03/226577.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/226577.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/09/03/226577.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/226577.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/226577.html</trackback:ping><description><![CDATA[怎样使用sed删除文件中的换行符？<br />这个问题困扰了我好伤时间，没有搞定。在网上搜得时候，终于找到了。<br /><div id="message8032016" class="t_msgfont"><br /><b><font color="#006400" size="4">杀鸡哪需牛刀？<br />
tr -d '\n'<br />
真的需要sed<br />
sed -nr ' H;<br />
$ {<br />
x;<br />
s/\n//g;<br />
p<br />
}'<br /><font color="#000000"><br /><font size="3">这是论坛里一个帖子，请参见</font><br /><font size="3"><a href="http://bbs.chinaunix.net/viewthread.php?tid=1060009">http://bbs.chinaunix.net/viewthread.php?tid=1060009</a><br /><br /></font></font></font></b></div><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/226577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-09-03 10:12 <a href="http://www.blogjava.net/zhyiwww/archive/2008/09/03/226577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript在IE和Firefox中的一些不同</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/27/224893.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 26 Aug 2008 16:15:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/27/224893.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/224893.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/27/224893.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/224893.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/224893.html</trackback:ping><description><![CDATA[
		<br />如何判断浏览器是IE<br /><br />if (navigator.userAgent.indexOf("MSIE") &gt;= 0) {<br />     // 浏览器是IE<br />   }<br /><br />在javascript使用时候的一些不同点，比如：<br />我想判断是点击了鼠标的那个键，左键还是右键，就需要使用不同的方法来判断<br /><br />在IE中<br />if(IE){<br />   //取得按的是那个键<br />   var but = window.event.button;<br />}<br /><br />else{<br /> //认为是firefox<br />  var but = event.button;<br />}<br /><br />这是取法不同。<br />取得的结果也是不同的。<br />在IE中，左键值是1，右键值是2<br />在Firefox中，左键值是0，右键值是2<br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/224893.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-27 00:15 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/27/224893.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript如何屏蔽右键(网络收集)</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224887.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 26 Aug 2008 15:30:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224887.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/224887.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224887.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/224887.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/224887.html</trackback:ping><description><![CDATA[
		<br />    &lt;body oncontextmenu="return false"&gt;<br />可以实现，屏蔽鼠标右键。<br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/224887.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-26 23:30 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/26/224887.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse中使用正则表达式</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224885.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 26 Aug 2008 15:12:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224885.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/224885.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/26/224885.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/224885.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/224885.html</trackback:ping><description><![CDATA[
		<br />&lt;script language="javascript" src="../scripts/aaaa.js"&gt;<br />    <br />&lt;/script&gt;<br />&lt;script language="javascript" src="../scripts/bbb.js"&gt;<br />    <br />&lt;/script&gt;<br />&lt;script language="javascript" src="../scripts/ccc.js"&gt;<br />    <br />&lt;/script&gt;<br />&lt;script language="javascript" src="../scripts/ddd.js"&gt;<br />    <br />&lt;/script&gt;<br /><br />如上面的一段代码,我希望批量的把后面的包含&lt;/script&gt;的代码去掉变成<br /><br />&lt;script language="javascript" src="../scripts/aaa.js"/&gt;<br />&lt;script language="javascript" src="../scripts/bbb.js"/&gt;<br />&lt;script language="javascript" src="../scripts/ccc.js"/&gt;<br />&lt;script language="javascript" src="../scripts/ddd.js"/&gt;<br /><br />怎么办呢<br />可以尝试一下下面的正则表达式：<br />&gt;\r\n\t\r\n&lt;/script&gt;<br />来查找目标内容，然后用<br />/&gt;<br />来替换就可以了<br /><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/224885.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-26 23:12 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/26/224885.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse中如何利用正则表达式选中空行</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224291.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 25 Aug 2008 13:24:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224291.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/224291.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224291.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/224291.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/224291.html</trackback:ping><description><![CDATA[^\s*\n<br />就可以实现。<br />如何想删除空行，使用替换功能，利用空来替换就可以了<img src ="http://www.blogjava.net/zhyiwww/aggbug/224291.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-25 21:24 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/25/224291.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>正则表达式如何取得HTML中body部分的内容</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224290.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 25 Aug 2008 13:14:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224290.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/224290.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/25/224290.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/224290.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/224290.html</trackback:ping><description><![CDATA[&lt;html&gt;<br />   .............<br />   &lt;body&gt;<br />     ............<br />..........<br />..........<br />.....<br /><br /><br />&lt;/body&gt;<br />.............<br />&lt;html&gt;<br />如上代码所示，在html文件中，我想选取所有的body部分的代码。<br />可以使用如下正则表达式来实现<br />&lt;body&gt;(.*\r\n)*&lt;/body&gt;<br />( 这是我在使用Eclipse是的一个小小的需求，自己就尝试了一下，结果解决了，所以，<br />仅以此记录一下自己的一点进步，以勉励自己继续努力。同时也希望能对看到此随笔的您有一点帮助。）<br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/224290.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-25 21:14 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/25/224290.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DOS下列出目录下的目录</title><link>http://www.blogjava.net/zhyiwww/archive/2008/08/21/223515.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Thu, 21 Aug 2008 07:18:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/08/21/223515.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/223515.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/08/21/223515.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/223515.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/223515.html</trackback:ping><description><![CDATA[在DOS下，很容易使用的一个命令就是dir,这个命令会列出这个目录向所有文件，包括目录和普通文件。<br />如果我只想列出目录下的目录，怎么办呢？<br />试一下 dir /AD就可以了。<img src ="http://www.blogjava.net/zhyiwww/aggbug/223515.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-08-21 15:18 <a href="http://www.blogjava.net/zhyiwww/archive/2008/08/21/223515.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows下CVSNT服务的配置</title><link>http://www.blogjava.net/zhyiwww/archive/2008/07/30/218639.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Wed, 30 Jul 2008 03:24:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/07/30/218639.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/218639.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/07/30/218639.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/218639.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/218639.html</trackback:ping><description><![CDATA[大概有以下几个步骤：<br />(一）安装CVSNT<br />(二）配置repositories<br />   <img height="438" alt="cvs1.PNG" src="http://www.blogjava.net/images/blogjava_net/zhyiwww/cvs/cvs1.PNG" width="668" border="0" /><br />(三)配置访问用户<br /><br />   在计算机配置里面添加一个组cvs,<br />   添加访问用户 a , b ,c ,d<br />   把用户a , b , c ,d 添加到cvs组里<br />(四)给cvs组的用户添加写权限<br /><img height="693" alt="cvs2.PNG" src="http://www.blogjava.net/images/blogjava_net/zhyiwww/cvs/cvs2.PNG" width="843" border="0" /><br /><br />至此，客户端的用户就可以访问您的CVS了。<br />如果没有第四步的配置，那么客户端用户可以checkout,但是不能commit<br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/218639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-07-30 11:24 <a href="http://www.blogjava.net/zhyiwww/archive/2008/07/30/218639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何取得空间两条新的交点</title><link>http://www.blogjava.net/zhyiwww/archive/2008/06/06/206230.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Fri, 06 Jun 2008 01:47:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/06/06/206230.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/206230.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/06/06/206230.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/206230.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/206230.html</trackback:ping><description><![CDATA[
		<br />近段，在学习geotools，去实现一些空间的运算。<br />下面的一段程序，实现了求得空间两条线的交点的程序，仅仅是一个demo,所以，就固定了两个线段的坐标，然后去求其交点。<br />需要导入geotools下的包，其实主要是用的是JTS。<br /><br /><br />package com.cybersoftchina.jts.demo;<br /><br />import java.util.ArrayList;<br />import java.util.List;<br /><br />import org.geotools.geometry.jts.FactoryFinder;<br /><br />import com.vividsolutions.jts.geom.Coordinate;<br />import com.vividsolutions.jts.geom.Geometry;<br />import com.vividsolutions.jts.geom.GeometryFactory;<br />import com.vividsolutions.jts.geom.LineString;<br />import com.vividsolutions.jts.io.ParseException;<br />import com.vividsolutions.jts.io.WKTReader;<br /><br />public class LineCross {<br /><br />    public void getCrossPoints() {     <br />        <br />        <br /><font color="#008000"><b>         Coordinate[] coordinates = new Coordinate[] {<br />         new Coordinate(116.29440, 39.90131),<br />         new Coordinate(116.41457, 39.84741) };<br />         Geometry g1 = new GeometryFactory().createLineString(coordinates);<br />        <br />         Coordinate[] coordinates1 = new Coordinate[] {<br />         new Coordinate(116.42418, 39.9136),<br />         new Coordinate(116.26968, 39.8395) };<br />         Geometry g2 = new GeometryFactory().createLineString(coordinates1);<br />        <br />         Geometry g = g1.intersection(g2);<br />         System.out.println(g);</b></font><br />        <br />        <br />    }<br /><br />    public void lineCross(){<br />        <br />        <br />        <br />    }<br />    <br />    public static void main(String[] args) {<br />        LineCross lc = new LineCross();<br />        lc.getCrossPoints();<br />    }<br /><br />}<br /><br />程序运行，返回的结果是：<br />POINT (116.34822145369408 39.87716939623774)<br />如果没有交点，那么返回的结果会告诉你是empty.<br /><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/206230.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-06-06 09:47 <a href="http://www.blogjava.net/zhyiwww/archive/2008/06/06/206230.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在IE浏览器下用javascript解析XML的三种方法</title><link>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205378.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 02 Jun 2008 09:49:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205378.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/205378.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205378.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/205378.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/205378.html</trackback:ping><description><![CDATA[我自己在学习的过程中才知道，在用javascript实现对xml的解析的时候，在不同的浏览器下面，有不同的方法。下面是在IE下面的解析方法，我说的三种，仅仅是我对于其做的一总结，希望能对正在学习ajax的您有所帮助。<br /><br />从服务器取得的XML结果：<br />  &lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br /> &lt;citys&gt;<br /> &lt;city&gt;shanghai&lt;/city&gt;<br /> &lt;city&gt;tianjin&lt;/city&gt;<br /> &lt;city&gt;chengdu&lt;/city&gt;<br /> &lt;city&gt;chongqing&lt;/city&gt;<br /> &lt;city&gt;hainan&lt;/city&gt;<br />&lt;/citys&gt;<br /><br />解析方法（一）<br />        var doc = response.responseXML;<br />        //alert(doc);<br />   <br />        var root = doc.documentElement;<br />        alert(root.text);<br />        <br />        var cities = root.childNodes;<br />        alert(cities.length);<br />        <br />        for(var i=0;i&lt;cities.length;i++){<br />          var city = cities[i];<br />          alert(city.text);<br />        }<br /><br />解析方法（二）：<br />        var cities = doc.selectNodes("/citys/city");<br />        alert(cities.length);<br />        <br />        for(var i=0;i&lt;cities.length;i++){<br />          var city = cities[i];<br />          alert(city.text);<br />        }<br />        <br />解析方法（三）：<br /><br />  var doc = response.responseXML;<br />        var cs = doc.getElementsByTagName("city");      <br />        alert(cs.length);<br />        <br />        for(var i=0;i&lt;cs.length;i++){<br />          vara = cs[i];<br />          //alert(a);<br />          //alert(a.nodeName);<br />          //alert(a.nodeValue);<br />          var b = a.childNodes;<br />          //alert(b);<br />          var c=b[0];<br />          alert(c.nodeValue);<br />        }<br /><br />只有第三种方法，可以在IE和Firefox下面通用。<br />如果有不妥之处，请路过的您多多指教。<br /><br /><a href="/Files/zhyiwww/AjaxDemo.rar">本例子源码下载</a><br /><br /><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/205378.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-06-02 17:49 <a href="http://www.blogjava.net/zhyiwww/archive/2008/06/02/205378.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在firefox浏览器下用javascript解析XML</title><link>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205376.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 02 Jun 2008 09:40:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205376.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/205376.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/06/02/205376.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/205376.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/205376.html</trackback:ping><description><![CDATA[刚接触ajax不久，想通过ajax实现从服务器上动态取得xml数据，然后，在客户端动态更新并显示。<br />但是，再firefox中，在取得xmlDom后，用在IE下面解析的办法（网上有很多的资料，也可以我的总结），怎么也不能取得标签文本的值。<br /><br />经过多次实践，才发现了下面的方法是可以实现的。原来很简单（见笑了…………）<br /><br />服务器返回XML结果如下：<br />  &lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br />- &lt;citys&gt;<br /> &lt;city&gt;shanghai&lt;/city&gt;<br /> &lt;city&gt;tianjin&lt;/city&gt;<br /> &lt;city&gt;chengdu&lt;/city&gt;<br /> &lt;city&gt;chongqing&lt;/city&gt;<br /> &lt;city&gt;hainan&lt;/city&gt;<br />  &lt;/citys&gt;<br /><br />==========================================================================<br />解析如下：<br /><br />// 取得的是xmlDom对象<br />var doc = response.responseXML;<br />         // 根据标签来取得List对象<br />        var cs = doc.getElementsByTagName("city");      <br />        alert(cs.length);<br />        <br />        for(var i=0;i&lt;cs.length;i++){<br />          var a = cs[i];<br />          //alert(a);<br />          //alert(a.nodeName);<br />          //alert(a.nodeValue);<br />          var b = a.childNodes;<br />          <font color="#0000ff"><b>(我的疑问：为什么需要取得b，cs[i]不就是一个city的对象了，为什么还需要取得数组，然后再取其元素,疑惑中)</b></font><br />          //alert(b);<br />          var c=b[0];<br />          alert(c.nodeValue);<br />        }<br /><br />cs取得的结果应该是：<br /> &lt;city&gt;shanghai&lt;/city&gt;<br /> &lt;city&gt;tianjin&lt;/city&gt;<br /> &lt;city&gt;chengdu&lt;/city&gt;<br /> &lt;city&gt;chongqing&lt;/city&gt;<br /> &lt;city&gt;hainan&lt;/city&gt;<br />city Element对象的一个集合。<br />所以，对于a来说，那么就应该是<br /> &lt;city&gt;shanghai&lt;/city&gt;<br />每一个city Element元素的对象了，但是，错了。此处得到的是一个<br />Element标签元素的一个数组。<br />也就是说<font color="#ff1493"><b>用childNodes方法取得的对象永远是数组对象</b></font>。那么，你想遍历其中元素的话，就需要用c对象来取。<br /><br /><a href="/Files/zhyiwww/AjaxDemo.rar">本例子源代码下载</a><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/205376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-06-02 17:40 <a href="http://www.blogjava.net/zhyiwww/archive/2008/06/02/205376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX中返回XML串但是不能返回XML DOM对象问题的解决</title><link>http://www.blogjava.net/zhyiwww/archive/2008/05/21/202017.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Wed, 21 May 2008 13:11:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/05/21/202017.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/202017.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/05/21/202017.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/202017.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/202017.html</trackback:ping><description><![CDATA[
		<p>我今天遇到了一个问题，在用post发送一个请求到服务器，然后，返回来了XML的串数据，我想通过response.responseXML来取得XML的Document对象，来实现用Javascript对XML文档的解析，但是，我就只能用response.responseText取得文本数据，通过response.responseXML取得的对象为null.结果一直也没有搞明白。<br />javascript的代码如下（用的prototype1.6.js）：<br /><br />function findpoi(){<br />    //alert("find ");  <br />    var pname=$F('pnid');<br />    alert(pname);<br />    <br />    var url="poiSearch.do";<br />    <br />    var opt = {<br />     method:'post',<br />     <br />     //contentType:'application/xml',<br />     //requestHeaders:'text/xml',<br />     onComplete:function(transport){<br />      alert(transport.status);<br />      document.title="ok";<br />      if(200==transport.status){<br />       <br />       //document.title="ok";<br />       var cntTxt=transport.responseText;<br />       alert(cntTxt);<br />       <br /><font color="#ff1493"><strong>       var dobj = transport.responseXML;<br />       alert("xml is :  "+dobj);<br /></strong></font>      (此处总是取得的是null对象)<br />       <br />       //var pl = cntTxt.getElementByName("poi");<br />       //alert(pl);<br />       <br />       var ajObj = Ajax.getTransport();<br />       alert(ajObj);<br />        <br />            <br />      }<br />     },<br />     postBody:"?city=beijing&amp;keyword=kfc"<br />     <br />    };<br />    <br />    var ajax=new Ajax.Request(url,opt); <br />    <br />   }<br /><br />我的struts action的代码如下：<br /><br />public ActionForward execute(ActionMapping mapping, ActionForm form,<br />   HttpServletRequest request, HttpServletResponse response) {<br />  DynaActionForm poiForm = (DynaActionForm) form;<br /><br />  String city = (String) poiForm.get("city");<br />  String keyword = (String) poiForm.get("keyword");</p>
		<p>
				<br />  <br />  Search bs = new Search();<br />  bs.baseSearch(city + "/" + keyword);</p>
		<p>  PoiDAO poidao = new PoiDAO();<br />  int count = 10;<br />  int page = 1;<br />  ArrayList arry = poidao.by_key_search("北京", "长安商场", count,<br />    page);<br />  System.out.println(arry.size());<br />  <br />  Document doc= DocumentFactory.getInstance().createDocument();<br />  doc.setXMLEncoding("UTF-8");<br />  Element root = doc.addElement("pois");<br />  <br />  root.addElement("poi")<br />  .addAttribute("pid", "1155")<br />  .addAttribute("longitude", "116.5864")<br />  .addAttribute("latitude", "39.8195");  <br />  <br />  <br />  ListIterator iter = arry.listIterator();<br />  while(iter.hasNext()){<br />  <br />   Poi p = (Poi)iter.next();<br />   //float lon = p.getLatitude();<br />   int id=p.getPoi_id();<br />   double lon=p.getLongitude();<br />   double lat = p.getLatitude();<br />   <br />   System.out.println("id is :  "+id);<br />   System.out.println("lon : " + lon);<br />   <br />   Element poi=root.addElement("poi")<br />    .addAttribute("pid", String.valueOf(p.getPoi_id()))<br />    .addAttribute("longitude", String.valueOf(lon))<br />    .addAttribute("latitude", String.valueOf(lat));   <br />  }<br />  <br />  try {<br />   PrintWriter w = response.getWriter();<br />   <br />   XMLWriter writer = new XMLWriter(w);<br />   writer.write(doc);<br />   <br />   writer.close();<br />   w.close();<br />   <br />  } catch (IOException e) {<br />   // TODO Auto-generated catch block<br />   e.printStackTrace();<br />  }<br />  <br />  return null;<br /> }<br /><br />下午的时候，总是在试图通过设置contentType来实现，结果是失败了。回来的路上，我就一直在想，能取到XML的串，不能取到XML的对象。那么也就是说，返回的数据是串，也就是文本类型。突然，我的脑海里闪现了一个问题，是不是返回的contentType没有设置成xml.<br />所以，我就在action里面，添加了<br />response.setContentType("text/xml");<br />重新测试，果然成功。<br />response.responseXML取到了对象。<br /><br />问题就这样得到了解决。<br /><br />问题总结：<br />如果想要通过AJAX的response.responseXML取得XML Document对象，那么就要在服务器的相应的时候设置ContextType为text/xml,否则的话，就只能去得到xml的文本串，不能得到DOM对象。<br /><br /><br /></p>
<img src ="http://www.blogjava.net/zhyiwww/aggbug/202017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-05-21 21:11 <a href="http://www.blogjava.net/zhyiwww/archive/2008/05/21/202017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Error filterStart错误问题的解决</title><link>http://www.blogjava.net/zhyiwww/archive/2008/05/21/201805.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Wed, 21 May 2008 00:51:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/05/21/201805.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/201805.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/05/21/201805.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/201805.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/201805.html</trackback:ping><description><![CDATA[现象：我在tomcat5.5下发布工程portal后，出现如下错误。<br /><br />log4j:WARN No appenders could be found for logger (org.apache.commons.digester.D<br />igester.sax).<br />log4j:WARN Please initialize the log4j system properly.<br />log4j:WARN No appenders could be found for logger (org.apache.commons.digester.D<br />igester).<br />log4j:WARN Please initialize the log4j system properly.<br />2008-5-21 8:37:05 org.apache.catalina.core.StandardContext start<br /><font color="#ff1493"><b>严重: Error filterStart<br />2008-5-21 8:37:05 org.apache.catalina.core.StandardContext start<br />严重: Context [/portal] startup failed due to previous errors</b></font><br />2008-5-21 8:37:06 org.apache.coyote.http11.Http11BaseProtocol start<br />信息: Starting Coyote HTTP/1.1 on http-8080<br />2008-5-21 8:37:06 org.apache.jk.common.ChannelSocket init<br />信息: JK: ajp13 listening on /0.0.0.0:8009<br />2008-5-21 8:37:06 org.apache.jk.server.JkMain start<br />信息: Jk running ID=0 time=0/32  config=null<br /><br />问题的解决：<br /><img src="http://www.blogjava.net/images/blogjava_net/zhyiwww/img/filter_error.PNG" alt="filter_error.PNG" border="0" height="516" width="676" /><br /><br />设置如上，就可以解决问题。<br /><br />错误原因分析：<br />因为，我之前先安装了JDK1.6,然后由于需要又安装了JDK1.5,所以eclipse默认的系统编译的class文件的版本可能是1.6的。所以，在tomcat的环境中就不能正常运行。<br /><br /><br /><img src ="http://www.blogjava.net/zhyiwww/aggbug/201805.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-05-21 08:51 <a href="http://www.blogjava.net/zhyiwww/archive/2008/05/21/201805.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Concrete Architecture of the Apache Web Server(zhuan zai)</title><link>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199548.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Fri, 09 May 2008 08:39:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199548.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/199548.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199548.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/199548.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/199548.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: http://www.cs.ucsb.edu/~tve/cs290i-sp01/papers/Concrete_Apache_Arch.htm																																																																The Concrete Architecture of the Apache Web S...&nbsp;&nbsp;<a href='http://www.blogjava.net/zhyiwww/archive/2008/05/09/199548.html'>阅读全文</a><img src ="http://www.blogjava.net/zhyiwww/aggbug/199548.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-05-09 16:39 <a href="http://www.blogjava.net/zhyiwww/archive/2008/05/09/199548.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Conceptual Architecture of the Apache Web Server(zhuan zai)</title><link>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199541.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Fri, 09 May 2008 08:30:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199541.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/199541.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2008/05/09/199541.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/199541.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/199541.html</trackback:ping><description><![CDATA[
		<center>
				<div align="left">
						<a href="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch.htm">
								<font size="+3">
										<b>
												<i>
														<font size="2">http://www.cs.ucsb.edu/~tve/cs290i-sp01/papers/Concept_Apache_Arch.htm</font>
												</i>
										</b>
								</font>
						</a>
						<br />
				</div>
				<font size="+3">
						<b>
								<i>The Conceptual Architecture of the Apache Web 
Server</i>
						</b>
				</font>
				<p>
				</p>
		</center>
		<table border="0" height="115" width="747">
				<tbody>
						<tr>
								<td>
										<p align="left">
												<font size="-0">
														<i>
																<b>Octavian Andrei 
      Dragoi</b>
														</i>,<br />Department of Computer Science,<br />University of 
      Waterloo,<br /><a href="mailto:oadragoi@neumann.uwaterloo.ca">mailto:oadragoi@neumann.uwaterloo.ca</a></font>
										</p>
								</td>
								<td>
										<p align="right">
												<font size="-0">Assignment 1<br />for CS746G <br /><i><b>January 
      26, 1999</b></i><br />  </font>
										</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>
				<b>
						<i>Abstract:</i>
				</b>
				<br />
		</p>
		<blockquote>
				<font size="-1">This report presents the conceptual (abstract) 
  architecture of the Apache web server. It tries to emphasize the overall 
  structure of the system, without going into implementation details, or 
  requiring such details to be previously known by the reader. The main purpose 
  is to make the architecture "intellectually tractable" (<a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Monroe97">[Monroe97]</a>).<br />The 
  conceptual architecture has been inferred from a number of Apache related 
  documents and from the way source files are grouped and named.<br />At a high 
  level the Apache server architecture is composed of a <i>core</i> that 
  implements the most basic functionality of a web server and a set of standard 
  <i>modules</i> that actually service the phases of handling an HTTP 
  request.<br />The server core accepts a HTTP request and implicitly invokes the 
  appropriate handlers, sequentially, in the appropriate order, to service the 
  request.<br />The report shows that the most similar architectural style (in the 
  sense of <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Garlan94">([Garlan94])</a>) 
  that can characterize the Apache architecture is <i>"implicit invocation"</i> 
  , although the notion of event does not exist in the architecture.<br />The 
  architecture offers great opportunities for extending or changing the Apache 
  functionality, by the means of adding or replacing modules. 
</font>
		</blockquote>
		<b>
				<i>Keywords: </i>
		</b>
		<blockquote>
				<font size="-1">Apache, conceptual architecture, abstract 
  architecture, web server</font>
		</blockquote>
		<b>
				<i>Available online at:</i>
		</b>
		<blockquote>
				<font size="-1">
						<a href="http://www.grad.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html">http://www.grad.math.uwaterloo.ca/~oadragoi/CS746G/a1/apache_conceptual_arch.html</a>
				</font>
		</blockquote> 
<p></p><h1><a name="ref_sec1"><font size="+2">1. Introduction</font></a></h1><a name="ref_sec1">The goal of this 
report is to present the conceptual (abstract) architecture of the Apache web 
server. Therefore it leaves aside implementation details and tries to be simple. 
As stated in </a><a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Monroe97">[Monroe97]</a> 
a good architectural description make the architecture "intellectually 
tractable". The paper might, sometimes, simplify the actual architecture order 
to achieved the previously stated desiderata.
<p>The report assumes no previous familiarity with the architecture of the 
Apache web server. So it can serve as an introductory reading on the 
architecture of the server.
</p><p>It should be noted that the architecture described here might not be entirely 
accurate. It has been inferred based on several <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref">sources</a>, 
including the overall structure of files and files name. It does not start from 
a previously existing complete design document. 
</p><h2><font size="+1">1.1. About Apache</font></h2>The Apache web server is 
currently the most popular web server, according to a <a href="http://www.netcraft.com/Survey/">NetCraft Survey</a>. It has maintained 
(and improved) its status since mid 1996. Originally, the project was based on 
NCSA httpd 1.3, were from the name ("<b>A PA</b>t<b>CH</b>y Server"). Since then 
the code base was completely rewritten, and evolved into a completely 
independent project.<br />One of the major reasons for the Apache success is the 
fact that is an "open source" project (any one can have access to Apache code 
source, and any one can write its on modules to suits one needs). (<i>source <a href="http://www.apache.org/docs/misc/FAQ.html">Apache FAQ</a></i>).
<p>May be here is the place to mention that Apache is written to be drop-in 
compatible with the NCSA server. This has design consequences due related to 
some configuration commands promoted by NCSA server, which cannot be naturally 
implemented in Apache. These commands are supported in a way that, somehow, is 
not in the general "philosophy" of the system.(<a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Thau96">[Thau96]</a>). 
(more details in the configuration section). 
</p><h2><font size="+1">1.2. Overview</font></h2>The report is organized as follows: 
<a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec2">Section 
2.</a> offers a high level view on the conceptual architecture of the Apache, 
outlining the main building bricks: the apache core and the apache modules. Next 
<a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec3">section 
(3.)</a> gives details on the conceptual architecture of the apache core and 
shows what the high level anatomy of a module. It also outlines the phases of 
handling an HTTP request as divided by the Apache architecture. It ends with a 
short description of the most representative standard modules. <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec4">Section 
4.</a> gives the conceptual architecture of the Apache server and analyze the 
concurrency in the system. <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec5">Section 
5.</a> present some additional issues related to the architecture of the system, 
mainly how configuration fit into the hole picture, how is data passed between 
core and modules and how resources are allocated and managed managed. Next <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec6">section 
(6.)</a> comments on the architectural styles (in the sense of <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Garlan94">[Garlan94]</a>, 
<a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Shaw96">[Shaw96]</a>) 
applicable to the Apache architecture, while the <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec7">Section 
7.</a> elaborates on extensibility issues. <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec9">Conclusions</a> 
and a <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_sec10">dictionary 
of terms </a>end the report. 
<h1><a name="ref_sec2"><font size="+2">2. High level Conceptual 
Architecture</font></a></h1>The function of a web server is to service requests 
made through HTTP protocol. Typically the server receive a request asking for a 
specific resource and returns the resource as a response. A client might 
reference in its request a file, and then that file is returned or, for example, 
a directory and then the content of that directory (codified in some suitable 
form) is returned. A client might also request a program, and it is the web 
server task to launch that program (CGI script) and to return the output of that 
program to the client. Various other resources might be referenced in client's 
request.<br />To summarize: the web server take a request, decode it, obtains the 
resource and hands it to the client.
<p>Additional concerns related to controlling access authorization and clients 
authorizations are also in the responsibility of the web server. As has been 
said the web server might execute programs as response to clients requests. It 
must ensure that this is not a threat for the host system (were the web server 
runs). In addition, the web server must be capable, not only to respond to a 
high rate of requests, but also to satisfy a request as quickly as possible.
</p><p></p><h2><font size="+1">2.1. Description</font></h2>As opposed to a monolithic server 
architecture in which all the activities are done by a single unit (in which 
different parts of handling a request are poorly delimited), Apache takes a 
modular approach. <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig1"><i>Figure 
1</i></a> illustrates the high level conceptual architecture. There is a 
<i>core</i> part of the server that is responsible for defining and following 
the steps in servicing a request and several <i>modules</i> that actually 
implement the different phases of handling the request.<br />As shall be seen 
later <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig1"><i>Figure 
1</i></a> does not capture an important characteristic of the architecture, 
namely, the predefined order in which modules are called, based on their 
advertised characteristics. 
<p></p><center><table align="center" border="0"><tbody><tr><td><a name="fig1"><img src="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch_files/fig1.gif" height="381" width="471" /></a></td></tr><tr><td><center><i><b>Figure 1.High level Conceptual 
    Architecture</b></i></center></td></tr></tbody></table></center>The idea is to 
keep the basic server code clean while allowing third-parties to override or 
extend even basic characteristics. 
<h1><a name="ref_sec3"><font size="+2">3. The core and the 
modules</font></a></h1>This section presents in more detail the components of 
the Apache server architecture. It presents the conceptual parts of the Apache 
core and how a request is decomposed in a set of phases. It also describe the 
anatomy of an Apache module (at a conceptual level). 
<h2><font size="+1">3.1. The core</font></h2>The core implements the basic 
functionality of the server. In addition it implements a number of utility 
functions. A worth mentioning utility, is the one that provides resources 
allocation on a per request pool. This facility is offered not only to the 
server core but also to modules.
<p>The following are the components of the core: 
</p><ul><li><code>http_protocol.c</code>: contains routines that directly communicates 
  with the client (through the socket connection), following the HTTP protocol. 
  All data transfers to the client are done using this component. 
  </li><li><code>http_main.c</code>: the component that startup the server and 
  contains the main server loop that waits for and accepts connections. It is 
  also in charge of managing timeouts. 
  </li><li><code>http_request.c</code> the component that handles the flow of the 
  request processing, dispatching control to the modules in the appropriate 
  order. It is also in charge with error handling. 
  </li><li><code>http_core.c</code>: the component implementing the most basic 
  functionality, which is described in a comment from a source file as being 
  <i>"just 'barely' functional enough to serve documents, though not terribly 
  well"</i>. Another interesting quote from a source file comment illustrates 
  very well the function of this component:<i>"this file could almost be 
  mod_core.c"</i>. Meaning that the component behaves like a module but has to 
  access some globals directly (which is not characteristic for a module). 
  </li><li>the component that take care of allocating resource pools, and keeping 
  track of them. (<code>alloc.c</code>) 
  </li><li>other utilities, including reading configuration files and managing the 
  information gathered from those files (<code>http_config.c</code>), as well as 
  support for virtual hosts. An important function of <code>http_config</code> 
  is that form the list of modules that will be called to service different 
  phases of the requests. </li></ul>In the above list the term <i>component 
</i>has been used in order to avoid the term <i>module</i> which will be used 
only to refers to <i>Apache modules</i><center><table align="center" border="0"><tbody><tr><td><a name="fig2"><img src="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch_files/fig2.gif" height="286" width="516" /></a></td></tr><tr><td><center><i><b>Figure 2. Architecture for Apache 
  core</b></i></center></td></tr></tbody></table></center><a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig1">Figure 
2.</a> depicts the interaction between different components of the core. As all 
components use the different utilities functions, connectors to UTILITIES and 
ALLOC have not been pictured. <i>Interaction</i> is used in a broader sense, 
meaning from calling a component service function to "conceptually" relinquish 
control to that component.
<p>It is interesting to observed that although the components of the core have 
rather distinct functionality, there is not a simple way to depict the 
interactions between them. Most of the architectural information being in the 
<i>names</i> of the modules rather than in the <i>connectors</i> between them.
</p><p>This is due to the considerably effort done by the designers to move 
everything that can be expressed as a separate entity into the modules part of 
the Apache server. What is left in the core are components too interconnected to 
be written as separate modules.
</p><p></p><h2><font size="+1">3.2. Request Phases</font></h2>A module implements only 
portion of the functionality for servicing a client request. More than one 
module are necessary to completely respond to a request. However module does not 
know one about the other. The control is transfered back and forth between the 
core and different modules. This is handled by dividing the handling of the 
request into a set of distinct phases.
<p>The following are the phases of handling a request for the Apache server: 
</p><ul><li>URI to filename translation; 
  </li><li>Check access based on host address, and other available information; 
  </li><li>Get an user id from the HTTP request and validate it; 
  </li><li>Authorize the user; 
  </li><li>Determine the MIME type of the requested object (the content type, the 
  encoding and the language); 
  </li><li>Fix-ups (for example replace aliases by the actual path); 
  </li><li>Send the actual data back to the client; 
  </li><li>Log the request; </li></ul>The phases are "controlled" by the http_request 
component of the core as has been already stated (see <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig2">Figure 
2.</a>).
<p></p><h2><font size="+1">3.3. Modules</font></h2>As has been said the role of the 
modules is to implement/override/extend the functionality of the Apache web 
server. All modules has the same interface to the core of the server. Module 
does not interact directly one with another. If they interact it is always 
through the Apache core.(implicit invocation as shall be seen).
<p></p><center><table align="center" border="0"><tbody><tr><td><a name="fig3"><img src="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch_files/fig3.gif" height="376" width="521" /></a></td></tr><tr><td><center><i><b>Figure 3. Architecture of an Apache 
    Module</b></i></center></td></tr></tbody></table></center>Apache (1.3) permits 
loading of modules when they are needed (they are dynamically linked with the 
server) and therefore the initialization and configuration methods might be 
called when the module is loaded as opposed to when the server is initialized.
<p></p><h2><font size="+1">3.4. Handlers</font></h2>A handler is for Apache the action 
that must be performed in some phase of servicing a request. For example when 
the requested object is a file, the handler that returns the the file must open 
the file, read the content of the file and hand the content of the file to the 
client (through apache core).
<p>Handlers are defined by modules, and a module might specify handlers for one, 
many or none of the phases of a request. Handlers are the part of the module 
that is called when the processing of the request enters the phase for which the 
handler is defined.
</p><p>The rationale behind having modules defining handlers for more than one phase 
is that a module might save internally data on the request being processed, and 
when its handlers for a subsequent phase of the request are called they might 
make use of those the data. In theory the module might even save data between 
different request (e.g. it might cash some file content for future use).
</p><p>It should be noted that there are additional functions exported by modules, 
related with configuration, and initialization, They are called in the startup 
phase of the server.
</p><p></p><h2><font size="+1">3.5. Standard Modules</font></h2>Apache comes with a set of 
standard modules for providing the complete functionality of a web server. The 
most representative/relevant among the standard modules are listed below. They 
also illustrate what kind of manipulation can be done at each phase. 
<ul><li>For URI to file name translation phase: 
  <ul><li><code>mod_userdir</code>: translate the user home directories into 
    actual paths mod_rewrite Apache 1.2 and up 
    </li><li><code>mod_rewrite</code>: rewrites URLs based on regular expressions, it 
    has additional handlers for fix-ups and for determining the mime type 
  </li></ul></li><li>For authentication / authorization phases: 
  <ul><li><code>mod_auth, mod_auth_anon,mod_auth_db, mod_auth_dbm </code>: User 
    authentication using text files, anonymous in FTP-style, using Berkeley DB 
    files, using DBM files. 
    </li><li><code>mod_access</code>: host based access control. </li></ul></li><li>For determining the MIME type of the requested object (the content type, 
  the encoding and the language): 
  <ul><li><code>mod_mime</code>: determines document types using file extensions. 
    </li><li><code>mod_mime_magic</code>: determines document types using "magic 
    numbers" (e.g. all gif files start with a certain code) </li></ul></li><li>For fix-ups phase: 
  <ul><li><code>mod_alias</code>: replace aliases by the actual path 
    </li><li><code>mod_env</code>: fix-up the environment (based on information in 
    configuration files) 
    </li><li><code>mod_speling</code>: automatically correct minor typos in URLs 
  </li></ul></li><li>For sending actual data back to the client: to chose the appropriate 
  module for this phase the mime type or the pseudo mime type (e.g. for a 
  CGI-script) is used. 
  <ul><li><code>mod_actions</code>: file type/method-based script execution 
    </li><li><code>mod_asis</code>: send the file as it is 
    </li><li><code>mod_autoindex</code>: send an automatic generated representation 
    of a directory listing 
    </li><li><code>mod_cgi</code>: invokes CGI scripts and returns the result 
    </li><li><code>mod_include</code>: handles server side includes (documents parse 
    by server which includes certain additional data before handing the document 
    to the client) 
    </li><li><code>mod_dir</code>: basic directory handling. 
    </li><li><code>mod_imap</code>: handles image-map file </li></ul></li><li>For logging the request phase: 
  <ul><li><code>mod_log_*</code>: various types of logging modules 
</li></ul></li></ul><h1><a name="ref_sec4"><font size="+2">4. Conceptual Architecture</font></a></h1><a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig1">Figure 
1</a> has shown which are the main components of the Apache web server and how 
they interact. However it does not illustrate the fact that handlers in modules 
are called in a fixed, predefined order, which is the order of the phases of 
servicing a request. <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig3">Figure 
3</a> tries to add the flow information mention above.
<p>For some phases only one module (handler in a module) can be called. Such 
phases are the authorization, the authentication, the return of the actual 
object to the client, and sometimes the URI to filename translation.<br />Other 
phases of servicing a request can have more that one handler called. For example 
there can be more than one module called to implement the logging part of the 
request.
</p><p>In some phases of processing a request all the handlers (in the registered 
modules) might be called until one returns a special code meaning that 
subsequent registered handlers for the current phase should not be called. An 
example is the URI to filename, translation phase.<br />Further more there might 
be the case that a handler returns an error code. In that case the processing of 
the request should stop and an error should be returned to the client (i.e. no 
other handlers are called, from this phase or subsequent phases). 
</p><p></p><center><table align="center" border="0"><tbody><tr><td><a name="fig4"><img src="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch_files/fig4.gif" height="698" width="821" /></a></td></tr><tr><td><center><i><b>Figure 4. Conceptual Architecture of Apache 
      Server</b></i></center></td></tr></tbody></table></center><h2><font size="+1">4.1. Concurrency in Apache</font></h2>Some web sites are 
heavily loaded (many requests per minute or even per second). Traditionally 
TCP/IP servers fork a new child to handle new incoming request from clients. 
However in the situation of a busy web site the overhead of fork-ing a huge 
number of children will simply suffocate the machine.
<p>As a consequence, Apache uses a different technique, namely <i>persistent 
server processes</i>. It forks a fixed number of children, right from the 
beginning. The children service incoming requests independently (different 
address spaces). Concurrency in Apache server is pictured in <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#fig5">Figure 
5.</a><br />Alternatively, when Apache compiles on MS Windows (as opposed to 
UNIX), a fixed number of threads is started from the beginning to service the 
incoming request (due probably to specific characteristic of this operating 
system).
</p><p></p><center><table align="center" border="0"><tbody><tr><td><a name="fig5"><img src="http://www.cs.ucsb.edu/%7Etve/cs290i-sp01/papers/Concept_Apache_Arch_files/fig5.gif" height="282" width="686" /></a></td></tr><tr><td><center><i><b>Figure 5. Concurrency on 
  Apache(UNIX)</b></i></center></td></tr></tbody></table></center>It is 
interesting that Apache server can dynamically control the number of children it 
forks (i.e. increasing or decreasing it), based on current load.
<p>From another point of view one might raise the question if a module is a 
separated process or can be implemented as a separated process. In Apache module 
is not a separated process. However some modules might fork new children in 
order to do their job. A readily example is the <code>mod_cgi</code> module, 
which handles the cgi script. It must fork a new child to execute the actual CGI 
script (after proper redirection of the standard input and output for the child 
process), and wait for it to finish. But this is a characteristic of the 
<code>mod_cgi</code>, many other modules need not to fork children.
</p><p>A different kind of module is the one that although it is not a separate 
process and does not for children it communicate through IPC mechanisms or 
sockets in with a different process (which might, for instance, be located on a 
different machine). An example of such module would be an authorization module 
which communicate with a server that manages users and passwords information. 
Even the CGI module might be implemented in this way (i.e. the actual script 
running as a completely different process not a child) which will result in 
improved security, but will have the communication overhead as a penalty. 
</p><h1><a name="ref_sec5"><font size="+2">5. Additional issues</font></a></h1>Some 
additional issues has been left aside from the description of the conceptual 
architecture and are treated in the next sections. 
<h2><font size="+1">5.1. Configuration of Apache Components</font></h2>One of the 
declared purposes of the Apache server architecture is to make it highly 
customizable. <br />Configuration files permit to customize not only the behavior 
of the server but the one of the modules too. Each module can advertise the 
custom commands it recognize from configuration files and will be called when 
such commands are found. Those commands might be completely new commands (not 
known in by the server core).<br />Apache permits even per directory customization 
via a file call <i>.htaccess</i>. This file also might contain commands 
understand only by modules.
<p>An interesting concept implemented by Apache is the one of <i>Virtual 
Hosts</i>. The server can respond to more than one name (i.e. www.example and 
www2.example), each assigned to one of the multiple IP addresses of the machine. 
The multiple IP addresses can be addresses associated with physical network 
interfaces or can be addresses associated with virtual network interfaces 
(simulated via logical devices by the operating system). Apache is able to 
"tell" under which name the host has been referenced and use different 
configuration options (e.g. allowing more access rights to users accessing the 
host through an interface networked in the local network, as opposed to users 
accessing the web server via an interface networked in the outside-the-company 
network). Modules also have accessed to this information.
</p><p>To summarize, the Apache "philosophy" related to configuration is: each 
component takes care of its own configuration, and configuration commands. The 
server core parse the configuration files and dispatches configuration commands 
to the appropriate modules to be interpreted (executed), or interprets 
(executes) the command itself if in particular was meant for it (i.e. is a 
configuration command for the core not for a module). 
</p><h2><font size="+1">5.2. Compatibility with NCSA server - impact on 
Architecture</font></h2>Starting from the code base of the NCSA server Apache 
was always design to be a drop-in replacement for this server. That means that 
Apache must understand and follow the configuration commands, and recognize the 
configuration files of the NCSA server. However this is not an easy task because 
some of the commands must affect behavior that appear in more than one module. 
Therefore one of the main principle of the Apache configuration machinery, 
namely each module takes care of its own configuration <i>must be broken </i>. 
<p>To "fix" this the problem commands of NCSA server (e.g. Options) are 
interpreted by the Apache core, even when they affect modules. The core make the 
configuration available to modules in the same way it make available the general 
configuration information. 
</p><h2><font size="+2">5.3. Data Flow / Data Structures</font></h2>Data is exchanged 
with various handlers in modules via a special structure called <i>request 
record</i> which includes information about the resource requested (e.g. 
filename), information about the configuration data related to the server, the 
virtual host, and the directory context in which the request is processed.
<p>Another key structure is the one the Apache core uses keep track of various 
modules. It is a linked list of <i>module records</i>, each holding all the 
information related to that module (e.g. handlers, configuration data per 
module). The module record is the mean by which the core calls the module. 
</p><h2><font size="+1">5.4.Resource Allocation - Resource Pool </font></h2>An 
interesting characteristic of the Apache server it the concept of <i>resource 
pool</i>. All resources related to a request (memory, file handlers) are 
allocated and handled through a dedicated resource pool. Further more, modules 
can define their own sub-resource pools if they want to manage private resources 
in a similar manner with general resources.
<p>What is characteristic for the resource pool, is that all resources are freed 
at once, when the resource pool is freed, preventing resource leakage. This is 
particularly important due to use of persistent processes. 
</p><h1><a name="ref_sec6"><font size="+2">6. Architectural Style</font></a></h1>The 
conceptual architecture described above, roughly approximate the style of 
<i>"implicit invocation"</i>. It should be noted however that the architecture 
is not exactly an <i>Event based architecture</i>, as specified in <a href="http://www.math.uwaterloo.ca/%7Eoadragoi/CS746G/a1/apache_conceptual_arch.html#ref_Garlan94">[Garlan94]</a>. 
It is usually the case with software architecture that cannot be clearly 
classified in a predefined style ("Real systems hybridize and amalgamate the 
pure style" - <a hreh="ref_Shaw96">[Shaw96]</a>).<br />To be more specific there 
is no such concept as many events that are announced (broadcast). Instead the 
only event is a request from a HTTP client, which starts a sequence of 
predictable implicit invocations.<br />The core has a fixed order in which will 
call the different handlers and will decide based on configuration information 
which is the order in which the handlers for the same phase are called.
<p>There is, however, something that might be compared with announcing an event, 
namely is the issuing of a sub-request by a module in order to "force" the core 
to perform some of the steps for a request on the sub-request (i.e. calling 
sequentially handlers for each servicing phase). However this is not 
(conceptually) a proper event, because the issuing module does not announce 
something to other (unknown to it) modules. It just a mean of "forcing" an 
implicit invocation.
</p><p>There are other characteristics of event systems (as summarized in <a hreh="ref_Shaw96">[Shaw96]</a>) that does not "fit" the description of the 
core-modules architecture of Apache. For example there is no control asynchrony, 
in the sense that the module issuing a the sub-request waits for the sub-request 
to be completed.<br />Also two phases of the request cannot be handled in parallel 
(one uses the outcome of the precedent one). More over the module is not a 
separate process, although it can fork children for some phases - like running a 
CGI script.
</p><p>So although the connectors between modules are <i>implicit invocations</i> 
and data flow is a tree - with some restrictions (e.g some phases cannot have 
more than one module to handle them, one phase is after the other) the 
architecture does not have other characteristics of the event systems.
</p><p>It can be argued however that as different instances of Apache 
(sub-processes) can handle in the same time request from different HTTP clients 
there is asynchrony. However the different instances are independent and do not 
shared information related to the requests processed.
</p><p>The way a request is serviced, with phases handled one after the other and 
the outcome of a request is used (most of the time) by the next phase, has some 
similarities with the general style of "pipe line" (as in <a hreh="ref_Shaw96">[Shaw96]</a>)). There is no upstream control (i.e. when the 
core invokes the handlers for one phase there is no data or control upstream). 
However, again, there is no asynchrony and more important the core <i>regain 
control</i> after each phase (i.e. after the handler has been invoked, and its 
job is done).
</p><p>Further more, some phases does not provide any change in the conceptual 
data-flow. And more significant, some handlers might be implemented by the same 
module and those handler might exchange information via private data of the 
module, bypassing the main data-flow. For example authorization and 
authentication does not change the request, they can only deny the execution of 
it. To conclude the pipeline is rather poorly reflected by the module 
structures, although conceptually the idea exists, therefore the implicit 
invocation seems more appropriate to characterize the general conceptual 
architectural style.
</p><p></p><h1><a name="ref_sec7"><font size="+2">7. Extensibility of Apache</font></a></h1>As 
it probably became obvious by now, Apache server architecture easily permits 
changes of the existing functionality or adding new functionality.<br />The 
modular approach and the effort made by the designers to move as much as 
possible from the web server functionality into separate modules make the task 
easier. For example if the way URI are translated into file names have to be 
extended, it is not necessary to change the module that does this task. It is 
sufficient to write a different module which will be called before or after the 
standard module has been called.
<p>Further more the ability of dynamically loading modules present in Apache 1.3 
release (no static linking with the server code), make the task of customizing 
the server even easier as there is no need to recompile the entire server. It is 
necessarily only to change some configuration files.<br />Another feature worth 
re-mentioning here is the capability of modules to define their own 
configuration commands, for which they are implicitly called to execute.
</p><p>An important part of the Apache web server that cannot be changed only by 
changing / adding a module is the one that implements the HTTP protocol. On the 
good, side the protocol is implemented as a separate piece of code 
(<code>http_protocol.c</code>), and all communication with the client is done 
through it, so only that part must be changed in order to implement a future 
version of HTTP. However there is no well defined API, as is the case for 
modules. 
</p><h1><a name="ref_sec8"><font size="+2">8. Conclusions</font></a></h1>Apache web 
server has a modular architecture with a core component that defines the most 
basic functionality of a web server (including the HTTP protocol and the reading 
of configuration files) and a number of modules which implements the steps of 
processing a HTTP request, offering handlers for one or more of the phases.
<p>The core is the one that accepts and manages HTTP connections and calls the 
handlers in modules in the appropriate order to service the current request.
</p><p>The architectural style can be characterized <i>implicit invocation</i> made 
by the server core on handlers implemented by the modules. Concurrency exists 
only between a number of persistent identical processes that service incoming 
HTTP requests on the same port. Modules are not implemented as separate process 
although it is possible to fork children or to cooperate with other independent 
process to handle a phase of processing a request.
</p><p>The functionality of Apache can be easily changed by writing new modules 
which complements or replace the existing one. The server is also highly 
configurable, at different levels (virtual host, directory, module) and modules 
can define their own configuration commands. 
</p><h1><a name="ref_sec9"><font size="+2">9. Dictionary of terms</font></a></h1><dt><strong>API</strong></dt><dd>Application Programming Interface
</dd><dd></dd><dt><strong>component</strong></dt><dd>term used throughout this report in order to avoid the term <i>module</i> 
which has been used in connection to (referring) an Apache module. This 
distinction is not a standard terminology, and has the only purpose to avoid 
confusion.
</dd><dd></dd><dt><strong>core (Apache core)</strong></dt><dd>part of the Apache server that defines and manages the steps in answering 
the request and implements the HTTP protocol.
</dd><dd></dd><dt><strong>CGI (CGI script)</strong></dt><dd>Common Gateway Interface, an interface describing how a web server passes 
parameters and receive results form another process on the same machine called 
CGI-script (executed by the web server when it receive a request referencing the 
script). 
</dd><dt><strong>handler</strong></dt><dd>a function of a module that will be implicitly invoked by the core to handle 
the phase of processing the HTTP request for which the handler was designed. 
</dd><dt><strong>HTTP</strong></dt><dd>Hypertext Transport Protocol, the protocol that coordinate how the hypertext 
files are transfered over the Internet. However any files can be transfered via 
HTTP. 
</dd><dt><strong>httpd</strong></dt><dd>the usual name for the web server (stands for HTTP daemon). 
</dd><dt><strong>IPC (IPC mechanisms)</strong></dt><dd>inter process communication mechanisms (e.g. queues, semaphores, shared 
memory) 
</dd><dt><strong>MIME type</strong></dt><dd>MIME stands for Multipurpose Internet Mail Extension. MIME types are the 
types (e.g. gif, html) of the entities defined in MIME request for comments 
</dd><dt><strong>module (Apache module)</strong></dt><dd>part of Apache server that provides some functionality in one or more phases 
of servicing an HTTP request. Its functions (handler) are implicitly invoked by 
the Apache core. It is interfaced with the Apache core by a special API. 
</dd><dt><strong>NCSA web server (NCSA httpd)</strong></dt><dd>the web server provided and maintained by the Development Group of the 
National Center for Super-computing Applications, at the University of Illinois 
at Urbana - Champaign 
</dd><dt><strong>request (HTTP client request)</strong></dt><dd>a message from the client containing information about the resource 
requested and how it is wanted to be delivered. 
</dd><dt><strong>resource (an HTTP resource)</strong></dt><dd>a network data object or service which can be identified by a URI 
</dd><dt><strong>response (HTTP server response)</strong></dt><dd>the response from the web server to an HTTP request, contains a header and 
usually the actual resource. The header contains status information and 
information on the resource (e.g. type, length of the binary representation). 
</dd><dt><strong>resource pool</strong></dt><dd>A large data structure allocated in one step by the Apache core, which holds 
the resources (memory blocks, open files) associated with a given request. When 
the resource pool is no longer needed it is deallocated in one step (memory is 
freed and files ore closed). 
</dd><dt><strong>URI</strong></dt><dd>Universal Resource Identifiers, are formated (fixed syntax) string which 
identify objects via location, and other characteristics. 
</dd><dt><strong>URL</strong></dt><dd>Uniform Resource Locators, a subclass of URI that locates resources based on 
their location and the protocol used to fetch them (e.g. 
http://www.uwaterloo.ca/index.html identifies the home page file of University 
of Waterloo) 
</dd><dt><strong>virtual host</strong></dt><dd>a single physical host might have more than one network interface, each with 
a different IP address and a different host name. For clients it acts as being a 
number of virtual hosts, one for each name. 
<dl></dl><h1><a name="ref_sec10"><font size="+2"></font></a><font size="+2"><a name="ref">10. 
References</a></font></h1></dd><dt><a name="ref_Thau96"><strong>[Thau96]</strong></a></dt><dd><a href="http://www5conf.inria.fr/fich_html/papers/P20/Overview.html"><i>Design 
considerations for the Apache Server API</i></a>, Robert Thau, Fifth 
International World Wide Web Conference, 1996, Paris. 
</dd><dt><a name="ref_APINotes"><strong>[APINotes]</strong></a></dt><dd><a href="http://modules.apache.org/doc/API.html"><i>Apache API notes 
</i></a>, Robert S. Thau. 
</dd><dt><a name="ref_ApacheDocs"><strong>[ApacheDocs]</strong></a></dt><dd><a href="http://www.apache.org/"><i>Apache server documentation</i></a></dd><dt><a name="ref_Garlan94"><strong>[Garlan94]</strong></a></dt><dd><a href="http://www.cs.cmu.edu/afs/cs/project/able/www/paper_abstracts/intro_softarch.html"><i>An 
Introduction to Software Architecture</i></a>, D. Garlan, M.Shaw, Advances in 
Software Engineering and Knowledge Engineering, Vol. I, World Scientific 
Publishing Company, 1993. 
</dd><dt><a name="ref_Monroe97"><strong>[Monroe97]</strong></a></dt><dd><a href="http://pecan.srv.cs.cmu.edu/afs/cs/project/able/www/paper_abstracts/ObjPatternsArch-ieee.html"><i>Architectural 
Styles, Design Patterns, and Objects</i></a>, R. Monroe, D. Kompanek, R. Melton, 
D. Garlan, IEEE Software, January 1997, pp 43-52. 
</dd><dt><a name="ref_Shaw96"><strong>[Shaw96]</strong></a></dt><dd><a href="http://www.cs.cmu.edu/afs/cs.cmu.edu/project/vit/www/paper_abstracts/Boxology.html"><i>A 
Field Guide to Boxology</i></a>, M. Shaw, P. Clementes, 1996 
<dl></dl></dd><img src ="http://www.blogjava.net/zhyiwww/aggbug/199541.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2008-05-09 16:30 <a href="http://www.blogjava.net/zhyiwww/archive/2008/05/09/199541.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>