Resin-3.0.18中出现的 "c:if" must not contain the '<' characte

本站移入Resin3.0.18后出现了一些问题,其中就是当调用一个jsp文件:/disall2.jsp时,出现下列报错,而这在原来的Resin2.*和Tomcat5.0.*是没有出现过的。


500 Servlet Exception

/disall2.jsp:1: org.xml.sax.SAXParseException: The value of attribute "test"

associated with an element type "c:if" must not contain the '<' character.

Resin-3.0.18 (built Fri, 24 Feb 2006 02:47:03 PST)

经过一行一行的检查文件中的<c:if>标记(JSTL的标记),发现下面一段可疑的代码:


     <c:if test="false">

      <font size="3">

     </c:if>

     <c:if test="false">

      <font size="4">

     </c:if>

里面有小于号“<”,于是试着把上面的代码改成:


     <c:if test="false">

      <font size="3">

     </c:if>

     <c:if test="false">

      <font size="4">

     </c:if>

这样,就OK了。

在JSTL的关系运算中,有两套等效的运算符。如:ge 相当于 >= ;lt 相当于 < ;le 相当于 <= 等等。

完整的有:


类别  运算符

算术运算符 + 、 - 、 * 、 / (或 div )和 % (或 mod )

关系运算符 == (或 eq )、 != (或 ne )、 < (或 lt )、 > (或 gt )、 <= (或 le )和 >= (或 ge )

逻辑运算符 && (或 and )、 || (或 or )和 ! (或 not )

验证运算符 empty

但是它们的使用有什么区别呢?我还不知道。谁知道了提一下,谢谢。

网页上几段script代码引起的网页正文加载问题

我发现诸如:

<script src="http://dict.cn/hc/" type="text/javascript"></script>

这类的script加载代码如果执行不能完成有可能引起整个网页的加载不能完成。

我发觉这类代码的执行是顺序进行的。也就是说,如果某段这类的代码没有执行完成的话,它后面的内容也不会执行。所以,如果后面有网页正文的内容的话,整个网页正文都显不出来。如果把这类代码放在了一个表格中,由于表格必须里面所有的内容加载完后才能显示出来,当这类代码的执行不能完成,所有表格的内容都显示不出来。

今天中午,我发现由于Dict.CN的划词代码(我放在网页的最前面的)执行不能完成,导致整个网页内容不能显示出来;还有,奇怪的是,今天cnzz的统计代码也不能执行完成,导致其后面的内容不能执行(如我统计帖子访问的计数代码,不是cnzz的统计计数,是我自己的用数据库保存的帖子访问计数。)

现在,我按:自己的页面统计计数代码,Dict.CN划词翻译代码,cnzz统计代码的顺序把这些代码放在了紧接</body>的前面,也是全部网页的最后。这样,这些代码就不会影响整个网页正文的加载了。

划词翻译的开关状况代码仍然是放在网页的最前面的,我想,这个开关状态代码没有调用Dict.CN网站上的资源,不会引起加载延迟吧。

附上面提到的几段script代码:

1、划词翻译状态开关代码,放在网页的最前面:


<span id="dict_status"></span>

下面的代码按序放在紧接</body>之前(这个位置科不科学还未考证):

2、本站自己的帖子页面计数代码:


<script language="javascript" src="/count.do?artID=<c:out value="${aGoal.articleID}"/>"></script>

3、Dict.CN的划词翻译代码:


<script src="http://dict.cn/hc/" type="text/javascript"></script>

<script type="text/javascript">

dictInit();

</script>

4、cnzz的页面访问统计代码:


<script src='http://s**.cnzz.com/stat.php?id=***&web_id=***&show=pic' language='JavaScript' charset='gb2312'></script>

看来,script在网页上用处真的很大,什么时候也该好好学一下了。

怎样控制iframe内嵌网页的位置

在日记静态页面嵌入jsp动态页面的一些总结和疑问中有一个问题如下:


1、页面菜单上部的用户信息是用iframe嵌入的,像下面:

   <!-- show user state with iframe framework -->

   <iframe frameborder="0" name="user_state" width="771" height="30"

scrolling="no" src="/common/userState.jsp"></iframe>

/common/userState.jsp是从当前session中取出用户的相关信息显示出来。

不过,我发现: 在firefox中位置不动的信息条在IE中却可以用鼠标上下移动,而且,始

位置在底部,还把字脚给挡住了,搞不懂怎么做了?

昨天,在把Dict.CN的部分免费学英语服务加在网站上的过程中,借鉴了iciba.com的多爱英文中的查词代码,把上面的代码改成下面这个样子,这样,在IE和firefox中这个iframe中的内容都能靠上正常显示了。如下:


<DIV><IFRAME border="0" marginWidth="0" marginHeight="0" src="/common/userState.jsp" frameBorder="no" width="771" scrolling="no" height="21"></IFRAME></DIV>

我不知道究竟是DIV的原因还是marginWidth或者marginHeight的原因,反正结果正常了。又是一个知其然不知其所以然的问题:)。

以后对这类技术还是应该进行系统的学习才是解决这些问题的根本。

把Dict.CN的部分免费学英语服务加在网站上

今天开始,我试着在用Dict.CN的部分服务:包括:划词、英语口语每日一句、中英文词及短语双向翻译。就是大家现在看到的本站每一网页的顶部那一排内容。Dict.CN他们的免费服务不止这些,完整的包括(摘自他们的使用帮助):

1. 在线拼音输入法

2. 在线Dict.CN机器人

3. QQ迷你门户

4. 划词助手-划遍天下网

5. 鼠标右键单词查询

6. Dict.CN站点划词翻译

7. Web API接口

8. 在您的主页上提供在线词典服务

9. 在您的博客上显示每日学口语的例句和发音

 

因为,Dict.CN的“中英文词及短语双向翻译”只适用于GB2312网页,在我的UTF-8网页上输入中文查询英文是乱码,不能工作。于是,我就把这个功能用iframe框架放在了一个GB2312的网页上,连带也把每日一句放进去了。因为那个划词翻译(也是可以中英文互译的)必须放在当前被翻译的页面中,所以就没有放进iframe框架内。

还有,如果为了避免加载速度影响整个网页的显示而采用原来使用的延迟加载技术(让del.icio.us不影响页面的加载(转帖)),好像划词翻译和每日一句就不会当鼠标移到上面而自动发音,不知道为什么。所以,就没有使用这种延迟加载技术。不过,现在来看,还没有看到Dict.CN因加载速度而影响整个网页加载的情况。服务的加载速度也许是这类网站发展壮大的关键因素之一,试想,你的服务和技术再好,却加载太慢,谁还有耐心等待你的优质服务?这也是这类网站要真正做大就必须想办法盈利的重大原因和前提之一。服务好-》盈利-》服务更好-》更盈利。。。,这才是这类网站(也许是更多的网站)做大做好,更好为网友服务的根本之道。

几个月前曾经试过的www.iciba.com的每日一句(在网站上显示每日一句>英语和在帖子中背单词),后来因为iciba的每日一句输出代码失效长达一个月以上就没有用了(取消了网站头部无效的金山词霸每日一句展示)。不过,金山词霸现在也专门推出了供其他网站调用资源的免费代码,包括(摘自他们的网站):

词典搜索

短句搜索

每日一句

每日 E文

即划即译

我不知道Dict.CN的服务究竟如何,也不知与iciba.com相比的优势和劣势,作为一个用户,我只用适合自己和适合上这个网站的朋友的服务。

附本站的用上述的Dict.CN的免费服务的代码,因为我是多个服务一起使用,就把每日一句中一个多余Dict.CN的链接去掉了(正常使用一般看不见这个链接,但是用linux下的w3m浏览器就看见了,而且在搜索引擎眼中这个链接应该是可见的),但是保留了查词功能中的Dict.CN的链接。实际上,Dict.CN的这个链接在我看来,从功能上的使用上来说仍然是多余的。但是,尊重Dict.CN的意见,特地保留了这个链接,也算是对Dict.CN为广大网友提供免费服务的赞赏吧:)。话又说转来,像单独的我们这样的小站,挂链接和不挂链接对Dict.CN也没有什么影响。Dict.CN只有取得许多网友的赞赏才能蓬勃发展,成为在线词典甚至在线英语学习的重量级网站。

下面是源码1:/common/dict.jsp,用<%@ include file="/common/dict.jsp" %>加在每一网页的顶部。


<table border="0" width="771" align="center">

<tr align="center">

<td width="105">

<span id="dict_status"></span>

<script src="http://dict.cn/hc/" type="text/javascript"></script>

<script type="text/javascript">

dictInit();

</script>

</td>

<td>

<DIV><IFRAME border="0" marginWidth="0" marginHeight="0" src="/common/dict_search.jsp" frameBorder="no" width="666" scrolling="no" height="45"></IFRAME></DIV>

</td>

</tr>

</table>

源码2:/common/dict_search.jsp


<%@ page contentType="text/html; charset=GB2312" %>

<html>

 <head>

  <title>

   Dict.CN english-chinese word search

  </title>

   <link rel="stylesheet" href="/common/web_font.css" type="text/css">

 </head>

 <body>

<table border="0" width="666" align="center">

 <tr align="center">

 <td>

 <span id="dict_daily">

 </span>

<script language="JavaScript" src="http://dict.cn/daily.php" defer="defer">

</script>

 </td>

 <td>

<form method="post" target="_blank"

action="http://dict.cn/search/">

<input maxlength=256 size=21 name=q><br>

<input type="submit" value="Look Up">

<a href="http://dict.cn" target="_blank">在线词典</a>

</form>

 </td>

 </tr>

 </table>

 </body>

</html>

上面的查词中有一个Dict.cn的链接,当我在linux的w3m浏览器输入了生词后按TAB键的焦点落在了链接上,而不是提交按纽。所以,我把这个链接移到了后面。我想,保留这个链接还是必要的。一是对Dict.CN意见的尊重,对他们服务的赞赏;二是这样做应该对他们的产品的推广有利,不管是从搜索引擎优化的角度还是让用户更好的记住他们:Dict.CN。一句话,Dict.CN在他们的网站上要求“定制效果时希望您能尽量保留在线词典的链接”是恰当的:)

Thinking in Patterns Ch. 13: Reducing interface complexity

Thinking in Patterns with Java V0.9: Chapter 13: Reducing interface complexity: TIPatterns.htm#_Toc41169743

1, Sections:

 Facade. 105

   Package as a variation of Facade  106

2, The main content and feeling:

  What is Facade? Bruce tell me:"If something is ugly, hide it inside an object.".

  After reading this chapter, I can got some below:

 

  1), Design pattern is really a pratical technique.

  Although I read this book, and know some of Facade, and know its example://:

facade:Facade.java, but, I feel I can't understand it without a real applying

of this pattern. Maybe, I will use it later.

  2), Just like Bruce's feeling:"To me, the Facade has a rather "procedural" (non-object-oriented) feel to it: you are just calling some functions to give you objects."

  3), Facade is most useful to C++ programmer, in java, "package" is a

build-in Facade.

 

3, Questions about programming:

  

  1), If it is that the function of Facade Pattern is only acting as a factory to create some objects? It can't call another object's method to process something in a static method just like below?


class A {

  void f(){}

}

public class B {

  static void doFinA() {

    (new A()).f();

  }

}

  

Then, I can do something like this:

B.doFinA();

4, Questions about english language:

1), Strange words:

    cast about, mold, first-cut, tax adviser, tax code, mediator, as if, to be

fair, clash, majority

2), Difficult sentences:

 

                                     incomplete

Thinking in Patterns Chapter 12: System decoupling

Thinking in Patterns with Java V0.9: Chapter 12: System decoupling: TIPatterns.htm#_Toc41169737

1, Sections:

Observer. 95

Observing flowers. 97

A visual example of observers. 101

Mediator. 103

Exercises. 104

2, The main content and feeling:

This is a really difficult reading experience for me in this chapter's

learning. After three times' reading, at last, I can say, Observer Pattern, I

got it.

1), Observer Pattern

From my own understanding with a simplest instance, Observer Pattern can be used in the situation below:

I am prepairing for dinner, I am an Observable; My mother is reading a book in the book room and waiting for dinner, She is an Observer.

When the dinner is ready, I send her a signal: A dinner begin! From my

Observable role, I just:

 setChanged(){/*dinner has ready*/}

 super.notifyObservers(); //notify her the dinner has ready

And she just:

update(){/* put the book into desk, go the dinner room to eat */}

A key of this pattern must be aware:

The Observable object's class you used must inherit from the base class:

java.util.Observable !

Because, in the base Observable class, notifyObservers() don't call

setChanged() method, before you notify the Observer, you must call it in you

own derived-class which inherited from Observable base class; Otherwise,

although you have notified Observer, they notice that "changed" flag hasn't

changed, they don't update() anything. Just an Observer say: yes, I get you

notify, but, I see you don't change anything, so, I needn't do a useless

thing.

Note, in the book, Bruce say:


To get an effect, you must inherit from Observable and somewhere in your derived-class code call setChanged( ). This is the method that sets the ?changed? flag, which means that when you call notifyObservers() all of the observers will, in fact, get notified. In the example above setChanged( ) is simply called within notifyObservers( ), but you could use any criterion you want to decide when to call setChanged( ).

I understood his meaning is: You can put the setChanged() code in anywhere of

your code. But, I think if you want Observer update() himself, you must do a

setChanged() before you call notifyObservers() in the

Observable object. Is there any wrong with me?

 

Another point is important of my understanding is:

One Observable Object can be tied with many of different Observer Object

dynamically. Just like the book's example below:


   ...

    f.opening().addObserver(ba.openObserver());

    f.opening().addObserver(bb.openObserver());

    f.closing().addObserver(ha.closeObserver());

    f.closing().addObserver(hb.closeObserver());

   ...

At last, the Observer Patterns descripted in this book is taken the use of standard java.util library. Of course, it must there are some other Observer Pattern implementions need me to learn.

2), Mediator


Sweep coupling under the rug, how is this different from MVC?

MVC has distinct model and view; mediator could be anything. MVC a flavor of

mediator

Why no more words in pattern of Mediator? So, I can't understand what is

Mediator. And, the sentence above I can't understand it yet. 

3, Questions about programming:

1), What is "callback"?

2), Notice, however, that the control of the flag?s state is protected, so that only an inheritor can decide what constitutes a change, and not the end user of the resulting derived Observer class.

   Who is "end user"?

3), Then it moves through the set and calls back to the update( ) member function of each Observer.

  Is there any "call back" action to the update() method of observer when observed object notify changes to observer?

4), What is Mediator Pattern?

5), Exercises.

4, Questions about english language:

1), Strange words:

Document-View Architecture, plot, textual, facilitate, potentially,

surrounding, observable, constitutes, in case, phenomena, have access to, come

in handy,

2), Difficult sentences:

Sweep coupling under the rug, how is this different from MVC?

MVC has distinct model and view; mediator could be anything. MVC a flavor of

mediator.

According to my learning, Sweep coupling under the rug, just like:(From

http://dict.cn)

sweep the dust under the carpet:

把不愉快的事情掩盖起来

 

                                     incomplete

搞懂java中的synchronized关键字

实际上,我关于java的基础知识的90%以上都来自Thinking in Java。对于其中的synchronized关键字,当时就是浏览一下,大概知道意思,也没有细看。后来一直没有用过这个关键字。昨天看Thinking in Patterns with Java中的Observer模式,看了其中的Observable类的源码,发现里面几乎所有的方法都用了synchronized关键字(不是全部),其中个别用了synchronized(this){}的区块。于是,我发觉有必要好好理解一下这个关键字了。

我再次看了侯捷译的Thinking in Java第二版中文版,得到有关synchronized的如下信息:

1、synchronized关键字的作用域有二种:

1)是某个对象实例内,synchronized aMethod(){}可以防止多个线程同时访问这个对象的synchronized方法(如果一个对象有多个synchronized方法,只要一个线程访问了其中的一个synchronized方法,其它线程不能同时访问这个对象中任何一个synchronized方法)。这时,不同的对象实例的synchronized方法是不相干扰的。也就是说,其它线程照样可以同时访问相同类的另一个对象实例中的synchronized方法;

2)是某个类的范围,synchronized static aStaticMethod{}防止多个线程同时访问这个类中的synchronized static 方法。它可以对类的所有对象实例起作用。

2、除了方法前用synchronized关键字,synchronized关键字还可以用于方法中的某个区块中,表示只对这个区块的资源实行互斥访问。用法是: synchronized(this){/*区块*/},它的作用域是当前对象;

3、synchronized关键字是不能继承的,也就是说,基类的方法synchronized f(){} 在继承类中并不自动是synchronized f(){},而是变成了f(){}。继承类需要你显式的指定它的某个方法为synchronized方法;

4、疑问:

我知道了有static区块(其中的加载时机好像也不清楚,需要学习一下,原来看Thinking in Java好像是说: static区块加载的时机是类的一个对象实例创建或类的一个static方法被访问,但是我今天早上看了javaeye.com上面的一个关于“<static块到底什么时候执行?-eway -JavaEye技术社区>”的文章后又有点迷糊了:),也许,需要认真学习一下JVM的内在机制才是理解这类问题最根本的途径),也有synchronized区块,那么,有synchronized static 区块吗?意思是问:有没有一个类作用域内的synchronized区块?

 

孩子的话我最懂!

一个令我感到有点骄傲的是:孩子的话我最懂!平时,她说的话,她的外婆和婆婆、甚至她的妈妈听几遍才能听得懂的话,基本上我一遍就能懂。也许,是我的耳朵比较灵敏吧:)

现在,自从上次孩子不在学校吃午餐后,每天早上送她去上幼儿园她都要问:今天哪个来接我?有时甚至中午送她去幼儿园都要问。可见,她是非常害怕在幼儿园里吃饭的,她怕一个人被留在幼儿园没人来接她。

孩子的记性也特别好,比如,我今天答应她,今天不买零食,明天给你买。于是,第二天,她就会问:爸爸,你昨天说的要给我买吃的。于是,我在惊叹于孩子的记忆力的同时,就不得不给她买了。

我们的孩子的所有情绪都会立即表现出来,所以,她说不喜欢我就是当时她的情绪对我不好。并不代表是一个她头脑里固定的概念,只是她当时心绪的反应。

我们孩子现在睡觉还可以了,原来睡觉不允许我们给她脱外衣,连身滚,而且睡得迟。现在一般9:00左右就睡了,睡之前也允许我们给她把外面的衣服脱了,只留内衣睡。早上也基本上能按时起来。只是有一点,她睡觉时爱把手伸出来,把手冻得冰冷。

这段时间,孩子在学写数字5了。在学校里,老师要求写一篇5。可能是她写的速度慢了,写不完,于是,在本子的后面全用叉填满。也算是写满一篇吧。

上次,连衣服称重有34斤了。是说,抱着去幼儿园挺累的。她不肯走路,如果不用自行车送她去幼儿园,就只有抱着或背着去了。送她去幼儿园是我的事,因为我上班就要经过她的幼儿园。

我们孩子的声音很大,说起话很响亮,有时争论起什么来,都怕她把嗓子震坏了。是否该教她说话、唱歌不要那么大声?又觉得好像不合适。

at last, I found a reason to restart english learning

I can't remember that I have broken english learning how long time. But, this time, I have to restart english learning again. There is a good reason is: Next April, I will participate english test for 职称评定(professional rank and titles grading, I don't know if it is right).

Although, I have heard maybe the english test will cancel in a day, but, we can't know when this day come. So, a best way is to learn it, and prepair for english test.

Which way should I use to learn it?

1, write a sentence every day;

2, learning english program tutorial continuely, like Thinking in Patterns with Java;