 
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>陈亚强的Blog－－我思，我行 &#187; ????</title>
	<atom:link href="http://www.chenyq.com/tags/technology/feed" rel="self" type="application/rss+xml" />
	<link>http://www.chenyq.com</link>
	<description>欢迎访问陈亚强的博客，这里将记录我创业历程，学习经验，生活点滴。</description>
	<lastBuildDate>Sat, 21 Aug 2010 16:08:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>原来apache 的oro没有\v</title>
		<link>http://www.chenyq.com/archives/27</link>
		<comments>http://www.chenyq.com/archives/27#comments</comments>
		<pubDate>Fri, 10 Aug 2007 02:39:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[????]]></category>

		<guid isPermaLink="false">http://www.chenyq.com/archives/27</guid>
		<description><![CDATA[一直以为apache的 oro的正则表达式规则和普通的一样,可以使用\v .前段时间发现程序运行后java变成jaa,div变成di。
百思不得其解，只好一步步调试。原来一句正则表达式出问题了。

[\\n\\f\\t\\v]*

去掉\\v 一切ok。 
]]></description>
			<content:encoded><![CDATA[<p>一直以为<a href="http://www.ewik.cn/tag-430-1.html">apache</a>的 oro的正则表达式规则和普通的一样,可以使用\v .前段时间发现程序运行后java变成jaa,div变成di。<br />
百思不得其解，只好一步步调试。原来一句正则表达式出问题了。</p>
<blockquote><p>
[\\n\\f\\t\\v]*
</p></blockquote>
<p>去掉\\v 一切ok。 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.chenyq.com/archives/27/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Scriptless JSP Applications with JSP2.0 Expression Language</title>
		<link>http://www.chenyq.com/archives/9</link>
		<comments>http://www.chenyq.com/archives/9#comments</comments>
		<pubDate>Wed, 02 May 2007 11:12:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[????]]></category>

		<guid isPermaLink="false">http://www.chenyq.com/archives/9</guid>
		<description><![CDATA[
版权申明：你可以任意转载此文，但必须保持文章的完整性，并且标明此文的出处，谢谢！
作者序：这是我4年前练手写的一篇英文技术文章，几乎没有公开过，出来献丑了。

Building Scriptless JSP Applications with JSP2.0 Expression Language
Level: Intermediate
Summary:
The Primary feature of JSP technology version 2.0 is its support for an expression languag, the expression language can now be used in JSP page instead of scriptlet expressions. In this article, first introduce some important concept about JSP2.0 Expression Language (EL), then demonstrate how to use [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
版权申明：你可以任意转载此文，但必须保持文章的完整性，并且标明此文的出处，谢谢！<br />
作者序：这是我4年前练手写的一篇英文技术文章，几乎没有公开过，出来献丑了。
</p></blockquote>
<p>Building Scriptless JSP Applications with JSP2.0 Expression Language</p>
<p>Level: Intermediate</p>
<p>Summary:</p>
<p>The Primary feature of JSP technology version 2.0 is its support for an expression languag, the expression language can now be used in JSP page instead of scriptlet expressions. In this article, first introduce some important concept about JSP2.0 Expression Language (EL), then demonstrate how to use EL to build a scriptless sample JSP application.<br />
Expression Language Introduction</p>
<p>The JavaServer Pages Standard Tag Library (JSTL) expression language is now integrated into JSP technology and has been upgraded to support functions. The expression language can now be used in JSP page instead of scriptlet expressions. By use of Expression Language, Web designers produce scriptless JSP pages that don&#8217;t contain any Java code.</p>
<p>An expression language makes it possible to easily access application data stored in JavaBeans components or JSP implicit objects.</p>
<p>For example, in JSP1.2, you can use the following code to access a JavaBeans component:</p>
<p>Listing 1. access JavaBeans components with JSP1.2 or earlier</p>
<p>&lt;jsp:useBean id=&#8221;user&#8221; class=&#8221;com.hellking.UserBean&#8221; scope=&#8221;page&#8221;/&gt;</p>
<p>&lt;%</p>
<p>  out.println(user);</p>
<p>  out.println(user.getUserName()); </p>
<p>%&gt;</p>
<p>In JSP2.0, you can access the property and variable by using EL through the following way:</p>
<p>Listing 2: access JavaBeans components by EL with JSP2.0</p>
<p>&lt;jsp:useBean id=&#8221;user&#8221; class=&#8221;com.hellking.UserBean&#8221; scope=&#8221;page&#8221;/&gt;</p>
<p>${user}&lt;br&gt;</p>
<p>${user.userName}</p>
<p>In listing2, we use “${user}” to access the JavaBean component, and use “${user.userName}” to access a nested property, and we can use “${user.userName.firstName}” to access more complex nested property.</p>
<p>The JSP expression evaluator is responsible for handling EL expressions, which may include literals and are enclosed by the ${ } characters. For example:</p>
<p>&lt;c:if test=&#8221;${user.age &lt; 30}&#8221; &gt;</p>
<p>  &#8230;</p>
<p>&lt;/c:if&gt;</p>
<p>We can use the Expression Language to set tag’s property, for example:</p>
<p>Listing 3 set tag’s property</p>
<p>&lt;c:set target=&#8221;${user}&#8221; property=&#8221;userName&#8221;&gt;sdf234sdfd&lt;/c:set&gt;</p>
<p>&lt;c:set var=&#8221;foo&#8221; value=&#8221;the user is ${user.userName} and the password is ${user.password}&#8221;/&gt;</p>
<p>The JSP container evaluates a variable that appears in an expression by looking up its value according to the behavior of PageContext.findAttribute(String). For example, when evaluating the expression ${user}, the container will look for user in the page, request, session, and application scopes and will return its value. If both the page and session has the attribute “user”, it will return the attribute of the page. If “user” is not found in any scope , null is returned.</p>
<p>The JSP expression language defines a set of implicit objects (Don&#8217;t confuse these with the JSP implicit objects), with the implicit objects, you can access variable in a very easy way. For example, in JSP1.2 or earlier, you use following code to access implicit objects and their values:</p>
<p>Listing 4 access implicit objects with JSP1.2 or earlier</p>
<p> &lt;%</p>
<p>session.setAttribute(&#8220;user&#8221;,&#8221;hellking&#8221;);</p>
<p>out.println(session.getAttribute(&#8220;user&#8221;));</p>
<p>out.println(request.getParameter(&#8220;password&#8221;));</p>
<p>%&gt;</p>
<p>And you may use the following code in JSP2.0:</p>
<p> Listing 5 access implicit objects with JSP2.0</p>
<p>&lt;c:set var=&#8221;user&#8221; value=&#8221;hellking&#8221; scope=&#8221;session&#8221;/&gt;           &lt;!&#8211;set a property in session &#8211;&gt;</p>
<p>${sessionScope.user}&lt;br&gt;                                 &lt;!&#8211; get a property in session &#8211;&gt;</p>
<p>${param.password}&lt;br&gt;                    &lt;!&#8211; equal to request.getParameter(&#8220;password&#8221;) &#8211;&gt;</p>
<p>You can see, Expression language provide a map between JSP implicit objects and their method(property).</p>
<p>You can access the JSP page context objects, page/request/session/application attributes (also known as JSP variables), JavaBean properties, collection elements, request parameters, initialization parameters, cookies, and HTTP headers.</p>
<p>With JSP 1.2, the expression language is available only to JSTL-based applications and tag libraries. JSP 2.0 makes the EL available to all JSP applications and all tag libraries (including the old taglibs designed for JSP 1.x). JSP 2.0 also simplifies tag library development, as you&#8217;ll see later in this article.</p>
<p>For more information about implicit objects map, see The Java Web Services Tutorial, http://java.sun.com/webservices/docs/1.2/tutorial/doc/JSPIntro7.html#wp71043.</p>
<p>NOTE:</p>
<p> JSP2.0 Expression Language is somewhat different from JSLT1.0 Expression Language. For Example, in JSTL1.0, use the following to output the variable’s value to client:</p>
<p>&lt;c:out value=”${test}”/&gt;</p>
<p>and in JSP2.0 EL, just use the following code:</p>
<p>${test}</p>
<p>Set up envirmonent</p>
<p>1.       Download Apache Tomcat 5.0 and setup it, see Resource.</p>
<p>2.       Create a web application in %Tomcat_Home%\webapps directory, the web application name is “el”.</p>
<p>3.       In the “el” application directory, create a sub directory WEB-INF; and then in WEB-INF directory, create a web application descriptor file: web.xml. Copy the following descriptor to web.xml file.</p>
<p>Listing 6 new web.xml descriptor</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243;?&gt;</p>
<p>&lt;web-app xmlns=&#8221;http://java.sun.com/xml/ns/j2ee&#8221;</p>
<p>    xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;</p>
<p>    xsi:schemaLocation=&#8221;http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd&#8221;</p>
<p>    version=&#8221;2.4&#8243;&gt;</p>
<p>  &lt;display-name&gt;jstl_el&lt;/display-name&gt;</p>
<p>  &lt;description&gt;</p>
<p>     a demo EL application</p>
<p>  &lt;/description&gt; </p>
<p>    &lt;welcome-file-list&gt;</p>
<p>      &lt;welcome-file&gt;viewUser.jsp&lt;/welcome-file&gt;</p>
<p>      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;</p>
<p>    &lt;/welcome-file-list&gt;</p>
<p>&lt;/web-app&gt;</p>
<p>NOTE: JSP2.0 descriptor is defined by w3c schema, and JSP1.x descriptor is defined by DTD. So I recommend you use the new descriptor, or if you use old descriptor, you JSP file may include:</p>
<p>&lt;%@ page isELIgnored =&#8221;false&#8221; %&gt;</p>
<p>4.       In the WEB-INF directory, create a sub directory, the name is lib. Copy jstl.jar and standard.jar form %Tomcat_Home%\webapps\jsp-examples\WEB-INF\lib to the lib directory.</p>
<p>5.       Test configuration. In the el directory, create a JSP whose name is el.jsp, and then copy the following code to the el.jsp file.</p>
<p>Listing 7 Test EL configuration</p>
<p>&lt;%@ taglib prefix=&#8221;c&#8221; uri=&#8221;http://java.sun.com/jsp/jstl/core&#8221; %&gt;</p>
<p>&lt;html&gt;</p>
<p>&lt;head&gt;</p>
<p>  &lt;title&gt;test jstl configuration&lt;/title&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body bgcolor=&#8221;#FFFFFF&#8221;&gt;</p>
<p>&lt;hr&gt;</p>
<p>&lt;c:set var=&#8221;test&#8221; value=&#8221;test_Value&#8221;/&gt;</p>
<p>&lt;hr&gt;</p>
<p>the value of test is:</p>
<p>${test}&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>Startup Tomcat, view the following URL from the browser:</p>
<p>http://127.0.0.1:8080/el/el.jsp</p>
<p>If the output is:</p>
<p>the value of test is: test_Value</p>
<p>Congratulation! the first EL application is run!</p>
<p>Build a Sample application</p>
<p>Now we discuss how to build a JSP application with JSP2.0 EL.</p>
<p>The application is a simple user register and manage program. The following is user register interface.</p>
<p>Figure 1 user register interface(userRegister.jsp)<br />
<img border=0 width=291 height=247 src="/wp-content/uploads/2007/05/image002.jpg"></p>
<p>And you can delete registered user in the following interface.</p>
<p>Figure2 view and delete registered user(viewUser.jsp)<br />
<img border=0   src="/wp-content/uploads/2007/05/image004.jpg"><br />
In the database, use the following script to create a table:</p>
<p>use test;</p>
<p>create table UserInfo(id varchar(20) not null,userName varchar(30),password varchar(20),age int,constraint  pk_UserInfo primary key (id));</p>
<p>And then you may copy the class file of the database server’s JDBC driver to the %Tomcat_Home%\common\lib directory.<br />
jstl.inc</p>
<p>jstl.inc file is a public file included by other JSP.</p>
<p>Listing 8 jstl.inc<br />
<code><br />
&lt;%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %&gt;</p>
<p>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;</p>
<p>&lt;%@ page language="java" errorPage="error.jsp" %&gt;</p>
<p>&lt;sql:setDataSource</p>
<p>  var="jspdev"</p>
<p>  driver="org.gjt.mm.mysql.Driver"</p>
<p>  url="jdbc:mysql:///test"</p>
<p>  user="root"</p>
<p>  password=""</p>
<p>  scope="session"</p>
<p>/&gt;<br />
</code><br />
You may modify the content of the &lt;sql:setDataSource&gt; tag according to the database settings.</p>
<p>NOTE</p>
<p>The uri of JSP2.0 tag is<br />
<code><br />
&lt;%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %&gt;</p>
<p>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;</p>
<p>but by default, the uri of JSTL1.0 tag is:</p>
<p>&lt;%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %&gt;</p>
<p>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;<br />
</code><br />
Don’t be confused.</p>
<p>userRegister.jsp</p>
<p>userRegister.jsp contain a HTML form, which used to submit user’s registration information. If the submitted registration information is invaluable, the error message and original parameter’s value is returned.</p>
<p>Listing 9 userRegister.jsp<br />
<code><br />
&lt;%@ include file="jstl.inc"%&gt;</p>
<p>…</p>
<p>note:${param.message}&lt;br&gt;&lt;/font&gt;</p>
<p>User Register：&lt;br&gt;&lt;hr&gt;</p>
<p>:::please input your register info and submit:::</p>
<p>&lt;form method="get" action="register_do.jsp" name="user" onsubmit="return validate(user.age)"&gt;</p>
<p> &lt;table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="5"&gt;</p>
<p>&lt;tr bgcolor="#cccccc"&gt;&lt;td align=right&gt;login id:&lt;input name="id" type="text" value="${param.id}" &gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr bgcolor="#cccccc"&gt;&lt;td align=right&gt;true name:&lt;input name="userName" type="text" value="${param.userName}"&gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr bgcolor="#cccccc"&gt;&lt;td align=right&gt;password：&lt;input name="password" type="password" value="${param.password}"&gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr bgcolor="#cccccc"&gt;&lt;td align=right&gt;your age:&lt;input name="age" type="text" value="${param.age}" &gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr bgcolor="#cccccc"&gt;&lt;td &gt;&lt;input type=submit value="submit"&gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;/table&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;c:import url="tail.html"/&gt;</p>
<p>…<br />
</code></p>
<p>register_do.jsp</p>
<p>In the register_do.jsp, first it validate the form’s parameter, if the parameter is invaluable, redirect back to the registration page; if the parameter is validly, execute the &lt;sql:update&gt; tag and save the data to database.</p>
<p>Listing 10 register_do.jsp<br />
<code><br />
&lt;%@ include file="jstl.inc"%&gt;</p>
<p>&lt;c:choose&gt;</p>
<p>         &lt;c:when test="${empty param.id or empty param.userName or empty param.password}"&gt;</p>
<p>           &lt;c:set var="nextPage" value="userRegister.jsp"/&gt;</p>
<p>           &lt;c:set var="message" value="column id. name .password can't be null!" scope="page"/&gt;</p>
<p>         &lt;/c:when&gt;</p>
<p>         &lt;c:when test="${empty param.age or param.age gt 100 or param.age lt 0}"&gt;</p>
<p>           &lt;c:set var="nextPage" value="userRegister.jsp"/&gt;</p>
<p>           &lt;c:set var="message"</p>
<p>value="column age can not be null, and age must be a integer between 0 and 100 !'"/&gt;</p>
<p>         &lt;/c:when&gt;</p>
<p>         &lt;c:otherwise&gt;</p>
<p>           &lt;sql:update var="user"</p>
<p>                      dataSource="${jspdev}"</p>
<p>                      sql="insert into UserInfo</p>
<p>values('${param.id}','${param.userName}','${param.password}','${param.age}')"/&gt;</p>
<p>         &lt;c:set var="nextPage" value="viewUser.jsp"/&gt;          </p>
<p>         &lt;c:set var="message" value="${param.id}"/&gt;</p>
<p>         &lt;/c:otherwise&gt;</p>
<p>&lt;/c:choose&gt;</p>
<p>&lt;c:redirect url="${nextPage}"&gt;</p>
<p>  &lt;c:param name="message" value="${message}"/&gt;</p>
<p>  &lt;c:param name="userName" value="${param.userName}"/&gt;</p>
<p>  &lt;c:param name="id" value="${param.id}"/&gt;</p>
<p>  &lt;c:param name="age" value="${param.age}"/&gt;</p>
<p>  &lt;c:param name="password" value="${param.password}"/&gt;</p>
<p>&lt;/c:redirect&gt;</p>
<p> </code></p>
<p>See the following EL:<br />
<code><br />
${empty param.id or empty param.userName or empty param.password}</p>
<p>is equal to:</p>
<p>&lt;%</p>
<p>if(request.getParameter("id").equals(null)||request.getParameter("id").equals(null)||request.getParameter("id").equals(null))</p>
<p>%&gt;</p>
<p>“empty” and “or” are EL operator, “empty param.id” means no request parameter “id” or the request parameter “id” has a null value. The following EL:</p>
<p>${empty param.age or param.age gt 100 or param.age lt 0}</p>
<p>is equal to:</p>
<p>&lt;%</p>
<p>if(request.getParameter("age").equals(null)||Integer.parseInt(request.getParameter("age"))&lt;0 ||Integer.parseInt(request.getParameter("age"))&gt;100)</p>
<p>%&gt;</p>
<p>“gt” and “lt” is EL operator, ”gt” means the mathematic operator ”&gt;”, ”lt” means the mathematic operator ”&lt;”.<br />
viewUser.jsp</p>
<p>viewUser.jsp is used to view the registered user’s information.</p>
<p>Listing 11 viewUser.jsp</p>
<p>&lt;%@ include file="jstl.inc"%&gt;</p>
<p>…</p>
<p>&lt;sql:query var="query" dataSource="${jspdev}"&gt;</p>
<p>   select * from userinfo</p>
<p>&lt;/sql:query&gt;</p>
<p>&lt;br&gt;&lt;br&gt;&lt;br&gt;</p>
<p>:::::::::the follow is all user in the system:::::::::&lt;br&gt;</p>
<p> &lt;table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="5"&gt;</p>
<p>  &lt;tr bgcolor="#cccccc"&gt;</p>
<p>  &lt;td&gt;id&lt;/td&gt;</p>
<p>  &lt;td&gt;name&lt;/td&gt;</p>
<p>  &lt;td&gt;age&lt;/td&gt;</p>
<p>  &lt;td&gt;delete&lt;/td&gt;</p>
<p>  &lt;/tr&gt;</p>
<p>  &lt;c:forEach var="row" items="${query.rows}"&gt;</p>
<p>  &lt;tr bgcolor="#FFFF88"&gt;</p>
<p>    &lt;td&gt; ${row.id}&lt;/td&gt;</p>
<p>    &lt;td&gt; ${row.userName}&lt;/td&gt;</p>
<p>    &lt;td&gt; ${row.age}&lt;/td&gt;  </p>
<p>    &lt;td&gt;&lt;a href="deleteUser_do.jsp?id=${row.id}"/&gt;delete&lt;/a&gt;&lt;/td&gt;</p>
<p>  &lt;/tr&gt;</p>
<p>  &lt;/c:forEach&gt;</p>
<p>…<br />
</code><br />
Unlike the JDBC programme, you can use ${row.id} EL to access the ResultSet Object. As you can see, ${row.id} is equal to the following scriptlet:</p>
<p>&lt;% out.println(resultSet.getString(“id”);%&gt;</p>
<p>       Because a JSP function is used in deleteUser_do.jsp, so let’s see something about JSP function.<br />
Use function in JSP2.0</p>
<p>JSP2.0 EL lets you call a Java class&#8217;s public static method using the following syntax:</p>
<p>${prefix:methodName(param1, param2, &#8230;)}</p>
<p>The JSP function must be declared in a tag library descriptor (TLD):</p>
<p>&lt;function&gt;</p>
<p>    &lt;name&gt;methodName&lt;/name&gt;</p>
<p>    &lt;function-class&gt;className&lt;/function-class&gt;</p>
<p>    &lt;function-signature&gt;</p>
<p>        returnType methodName(param1Type, param2Type, &#8230;)</p>
<p>    &lt;/function-signature&gt;</p>
<p>&lt;/function&gt;</p>
<p>The Java class doesn&#8217;t have to implement any special interface. The only requirement is to make the Java method public and static.</p>
<p>The following is the function’s class used in the demo application.</p>
<p>Listing 12 StringUtil.java</p>
<p>package com.hellking;</p>
<p>public class StringUtil</p>
<p>{</p>
<p>         public static String trim(String s1)</p>
<p>         {</p>
<p>                    return s1.trim();</p>
<p>         }</p>
<p>}</p>
<p>As mentioned earlier, the JSP function must be declared in a tag library descriptor. The functions.tld file defines some version number, the library&#8217;s URI, the function&#8217;s name, the name of the class containing the static method, and the method&#8217;s signature. The URI doesn&#8217;t have to point to an existing Web resource, but it must be unique. You may not use the same URI for two different tag libraries.</p>
<p>Here is the functions.tld file&#8217;s content:</p>
<p>Listing 13 functions.tld</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243; ?&gt;</p>
<p>&lt;taglib xmlns=&#8221;http://java.sun.com/xml/ns/j2ee&#8221;</p>
<p>    xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;</p>
<p>    xsi:schemaLocation=&#8221;http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd&#8221;</p>
<p>    version=&#8221;2.0&#8243;&gt;</p>
<p>  &lt;tlib-version&gt;1.0&lt;/tlib-version&gt;</p>
<p>  &lt;jsp-version&gt;1.2&lt;/jsp-version&gt;</p>
<p>  &lt;short-name&gt;function&lt;/short-name&gt;</p>
<p>  &lt;uri&gt;http://hellking.com/function&lt;/uri&gt;</p>
<p>  &lt;display-name&gt;JSTL sql RT&lt;/display-name&gt;</p>
<p>  &lt;description&gt;my function&lt;/description&gt; </p>
<p>  &lt;function&gt;</p>
<p>           &lt;name&gt;trim&lt;/name&gt;</p>
<p>           &lt;function-class&gt;com.hellking.StringUtil&lt;/function-class&gt;</p>
<p>           &lt;function-signature&gt;java.lang.String trim(java.lang.String)&lt;/function-signature&gt;</p>
<p>  &lt;/function&gt;   </p>
<p>&lt;/taglib&gt;</p>
<p>The functions.tld file must be placed into the Web application&#8217;s /WEB-INF directory. The same directory also contains the web.xml application descriptor, which declares the library within a &lt;taglib&gt; element. Add the following descriptor to the web.xml descriptor file.</p>
<p>Listing 14</p>
<p>&lt;taglib&gt;</p>
<p>        &lt;taglib-uri&gt;http://hellking.com/function&lt;/taglib-uri&gt;</p>
<p>        &lt;taglib-location&gt;/WEB-INF/functions.tld&lt;/taglib-location&gt;</p>
<p>&lt;/taglib&gt;</p>
<p>Now let’s see the usage of the JSP function.</p>
<p>Listing 11 deleteUser_do.jsp</p>
<p>&lt;%@ taglib prefix=&#8221;myfun&#8221; uri=&#8221;http://hellking.com/function&#8221;%&gt;</p>
<p>&lt;%@ include file=&#8221;jstl.inc&#8221;%&gt;</p>
<p>&lt;sql:update var=&#8221;user&#8221;</p>
<p>            dataSource=&#8221;${jspdev}&#8221;</p>
<p>            sql=&#8221;delete from UserInfo where id=&#8217;${myfun:trim(param.id)}&#8217;&#8221;/&gt;</p>
<p>&lt;c:redirect url=&#8221;viewUser.jsp&#8221;/&gt;</p>
<p>Before calling the trim () function, the deleteUser_do.jsp page must specify the function&#8217;s prefix and the library&#8217;s Uniform Resource Identifier (URI):</p>
<p>&lt;%@ taglib prefix=&#8221;myfun&#8221; uri=&#8221;http://hellking.com/function&#8221;%&gt;</p>
<p>And then we can use the function as the following way:</p>
<p>${myfun:trim(param.id)}</p>
<p>“myfun” is the prefix of the tag, “trim()” is name of the function defined in the tag library&#8217;s descriptor.</p>
<p>Resource:</p>
<p>Down the sample code here .</p>
<p>Download Tomcat 5 to run the JSP 2.0 examples:</p>
<p>http://jakarta.apache.org/builds/jakarta-tomcat/release</p>
<p>The Java Web Services Tutorial:</p>
<p>http://java.sun.com/webservices/docs/1.2/tutorial/doc/index.html</p>
<p>The JSP homepage: http://java.sun.com/products/jsp</p>
<p>The JSTL homepage:</p>
<p>http://java.sun.com/products/jsp/jstl</p>
<p>The JSP 2.0 specification:</p>
<p>http://jcp.org/aboutJava/communityprocess/first/jsr152/index2.html</p>
<p>The J2EE 1.4 Tutorial has a few chapters about JSP 2.0:</p>
<p>http://java.sun.com/j2ee/1.4/docs/tutorial</p>
<p>Call JavaBean methods from JSP 2.0 pages:</p>
<p>http://www.javaworld.com/javaworld/jw-05-2003/jw-0523-calltag.html</p>
<p>Apache Tomcat 5 supports JSP 2.0:</p>
<p>http://jakarta.apache.org/tomcat</p>
<p>A JSTL primer, Part 1: The expression language:</p>
<p>http://www-106.ibm.com/developerworks/java/library/j-jstl0211.html</p>
<p>About the author</p>
<p>Ya qiang Chen, a professional J2EE programmer, he has three years J2EE experience. He is interested in J2EE and Web Services technology. Except successful J2EE project, he also has written some books and articles about J2EE/Web Services program. Contact Ya qiang Chen at cyqcims@mail.tsinghua.edu.cn.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chenyq.com/archives/9/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>以前写过的一些技术文章</title>
		<link>http://www.chenyq.com/archives/6</link>
		<comments>http://www.chenyq.com/archives/6#comments</comments>
		<pubDate>Wed, 02 May 2007 10:05:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[????]]></category>

		<guid isPermaLink="false">http://www.chenyq.com/archives/6</guid>
		<description><![CDATA[3年前写的稿子了，主要发表在IBM DeveloperWorks网站上。在这里整理一下。由于技术有限，仅做参考，欢迎批评指正。
Java相关：

J2EE连接器开发实践之一: J2EE连接器的开发
本文基于J2EE连接器体系结构，介绍一个典型的资源适配器案例开发的过程和开发技巧，然后开发客户端，并在客户端通过连接器调用资源层。学习完本文，读者将能理解JCA的体系结构和开发的各个细节，并且能自主开发新的J2EE连接器。http://www.ibm.com/developerworks/cn/java/l-jca1/  
在不同平台下部署J2EE连接器和J2EE应用
本文基于J2EE连接器体系结构，介绍一个典型的资源适配器案例开发的过程和开发技巧，然后开发客户端，并在客户端通过连接器调用资源层。学习完本文，读者将能理解JCA的体系结构和开发的各个细节，并且能自主开发新的J2EE连接器。http://www.ibm.com/developerworks/cn/java/l-jca2/
使用Hibernate来实现持久对象
对象、关系的映射（ORM）是一种耗时的工作，在Java环境下，有几种框架来表示持久数据，如实体Bean、OJB、JDO、Hibernate等。 Hibernate是一种新的ORM映射工具，它不仅提供了从Java类到数据表的映射，也提供了数据查询和恢复等机制。本文介绍怎么在Web应用开发中配置Hibernate的环境，并且使用Hibernate来开发一个具体的实例。
在Hibernate中实现复杂的数据映射
在前一篇文章《使用Hibernate来操作持久对象》中，介绍了Hibernate的基本概念，然后用实例演示了怎么在Web应用中使用 Hibernate来封装持久数据对象。然而在现实的项目中，我们往往需要操作多个数据表，并且多个表之间往往存在复杂的关系，在本文，将介绍怎么在 Hibernate中描述多个表的映射关系，并且演示怎么操作关系复杂的持久对象。
http://www.ibm.com/developerworks/cn/java/l-hibernate2/index.html

Web 服务开发相关


        
          在J2EE 组件中引用和查找 Web 服务
        
本文将讨论怎么在 J2EE 组件中引用 Web 服务、并且通过 JNDI 来查找 Web 服务。http://www.ibm.com/developerworks/cn/webservices/ws-jndi/index.html

        
  [...]]]></description>
			<content:encoded><![CDATA[<p>3年前写的稿子了，主要发表在IBM DeveloperWorks网站上。在这里整理一下。由于技术有限，仅做参考，欢迎批评指正。<br />
<strong>Java相关：</strong></p>
<ul>
<li><a href="http://www.ibm.com/developerworks/cn/java/l-jca1/ ">J2EE连接器开发实践之一: J2EE连接器的开发</a></li>
<p>本文基于J2EE连接器体系结构，介绍一个典型的资源适配器案例开发的过程和开发技巧，然后开发客户端，并在客户端通过连接器调用资源层。学习完本文，读者将能理解JCA的体系结构和开发的各个细节，并且能自主开发新的J2EE连接器。http://www.ibm.com/developerworks/cn/java/l-jca1/  </p>
<li><a href="http://www.ibm.com/developerworks/cn/java/l-jca2/">在不同平台下部署J2EE连接器和J2EE应用</a></li>
<p>本文基于J2EE连接器体系结构，介绍一个典型的资源适配器案例开发的过程和开发技巧，然后开发客户端，并在客户端通过连接器调用资源层。学习完本文，读者将能理解JCA的体系结构和开发的各个细节，并且能自主开发新的J2EE连接器。http://www.ibm.com/developerworks/cn/java/l-jca2/</p>
<li><a href="http://www-128.ibm.com/developerworks/cn/java/l-hibernate1/">使用Hibernate来实现持久对象</a></li>
<p>对象、关系的映射（ORM）是一种耗时的工作，在Java环境下，有几种框架来表示持久数据，如实体Bean、OJB、JDO、Hibernate等。 Hibernate是一种新的ORM映射工具，它不仅提供了从Java类到数据表的映射，也提供了数据查询和恢复等机制。本文介绍怎么在Web应用开发中配置Hibernate的环境，并且使用Hibernate来开发一个具体的实例。</p>
<li><a href="http://www.ibm.com/developerworks/cn/java/l-hibernate2/index.html">在Hibernate中实现复杂的数据映射</a></li>
<p>在前一篇文章《使用Hibernate来操作持久对象》中，介绍了Hibernate的基本概念，然后用实例演示了怎么在Web应用中使用 Hibernate来封装持久数据对象。然而在现实的项目中，我们往往需要操作多个数据表，并且多个表之间往往存在复杂的关系，在本文，将介绍怎么在 Hibernate中描述多个表的映射关系，并且演示怎么操作关系复杂的持久对象。</p>
<p>http://www.ibm.com/developerworks/cn/java/l-hibernate2/index.html</p>
</ul>
<p><strong>Web 服务开发相关</strong></p>
<ul>
<p><li>
        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jndi/index.html">在J2EE 组件中引用和查找 Web 服务</a></p>
<p>        </b></p>
<p>本文将讨论怎么在 J2EE 组件中引用 Web 服务、并且通过 JNDI 来查找 Web 服务。http://www.ibm.com/developerworks/cn/webservices/ws-jndi/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jxmap/index.html">例析JAX-RPC 1.1中的Java/XML数据类型映射</a></p>
<p>        </b></p>
<p>本文将讨论JAX-RPC1.1中JAVA编程语言的数据类型与XML Schema数据类型之间的映射，并且提供具体的映射实例。http://www.ibm.com/developerworks/cn/webservices/ws-jxmap/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-session/index.html">JAX-RPC和Web服务会话状态的保持</a></p>
<p>        </b></p>
<p>本文首先讨论了Web服务会话状态的保持方法，然后结合JAX-RPC来介绍怎么在Web服务调用过程中保持客户端的会话状态，并且提供了服务端和不同类型客户端的调用实例。http://www.ibm.com/developerworks/cn/webservices/ws-session/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-ejb21/index.html">使用EJB2.1无状态会话Bean作为Web服务端点</a></p>
<p>        </b></p>
<p>本文介绍怎样在J2EE1.4平台下使用EJB2.1规范开发、打包、部署Web服务。http://www.ibm.com/developerworks/cn/webservices/ws-ejb21/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-j2ee14/index.html">J2EE 1.4 平台和Web服务</a></p>
<p>        </b></p>
<p>本文介绍了J2EE1.4平台中Web服务的构架，以及Web服务的最新规范、技术和开发工具。http://www.ibm.com/developerworks/cn/webservices/ws-j2ee14/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/xml/x-tipjaxrpc/index.html">技巧：用 JAX-RPC 发送与接收 SOAP 消息</a></p>
<p>        </b></p>
<p>在本技巧中介绍了 JAX-RPC，这是一种 Java API，有了它，应用程序不需要理解 SOAP 消息传递协议的细节，就可以与 Web 服务通信。http://www.ibm.com/developerworks/cn/xml/x-tipjaxrpc/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-handler/index.html">使用Handler来增强Web服务的功能</a></p>
<p>        </b></p>
<p>本文从SOAP消息中Handler的基本概念入手，逐步深入讨论Handler的各种典型使用（生成日志、用户认证、用户授权、信息加密/解密）以及实现方法。http://www.ibm.com/developerworks/cn/webservices/ws-handler/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-lob/index.html">在SOAP消息中传输BLOB和CLOB数据</a></p>
<p>        </b></p>
<p>本文介绍在SOAP消息中传输BOLB和CLOB数据的方法，然后为以图像传输为例子讨论BLOB、CLOB数据传输的编程实现方法。http://www.ibm.com/developerworks/cn/webservices/ws-lob/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jax-rpc/part2/index.html">用JAX-RPC开发Web服务：EJB作为Web服务端点</a></p>
<p>        </b></p>
<p>本文结合以前的案例，用EJB实现为Web服务端点，然后在客户端进行调用，最后把JAXM开发Web服务合JAX-RPC开发Web服务进行一个比较。http://www.ibm.com/developerworks/cn/webservices/ws-jax-rpc/part2/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jax-rpc/part1/index.html">用JAX-RPC开发Web服务：Servlet作为Web服务端点</a></p>
<p>        </b></p>
<p>本文首先介绍JAX-RPC基本构架，然后重点讨论把Servlet作为JAX-RPC Web服务端点时的开发步骤，以及各个步骤中要使用的工具和编程技巧。http://www.ibm.com/developerworks/cn/webservices/ws-jax-rpc/part1/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jaxrpc/part2/index.html">开发者关于 JAX-RPC 的介绍，第 2 部分：研究 JAX-RPC 的规范提高 Web 服务互操作性</a></p>
<p>        </b></p>
<p>本文讲述了 JAX-RPC 标准的异常处理机制和潜在的运行时服务，说明了怎样构建基于 JAVA 的互操作 Web 服务。http://www.ibm.com/developerworks/cn/webservices/ws-jaxrpc/part2/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jaxrpc/part1/index.html">开发者关于 JAX-RPC 的介绍，第 1 部分：了解 JAX-RPC 类型映射系统的各个方面</a></p>
<p>        </b></p>
<p>本文讲述如何把 XML 类型转换为 Java 类型，以确保 Web 服务客户机和基于 Java 的应用程序之间能够进行平稳的数据交换。http://www.ibm.com/developerworks/cn/webservices/ws-jaxrpc/part1/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jaxm/part2/index.html">JAXM开发Web服务的构架和模式</a></p>
<p>        </b></p>
<p>本文将结合前一篇文章《用JAXM开发Web服务》的案例来讨论JAXM Web服务的构架和设计模式。http://www.ibm.com/developerworks/cn/webservices/ws-jaxm/part2/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/webservices/ws-jaxm/part1/index.html">用JAXM开发Web服务</a></p>
<p>        </b></p>
<p>本文介绍JAXM Web服务开发的基本概念，然后结合一个具体的案例来介绍使用JAXM开发Web服务中要使用的编程技术和编程技巧。http://www.ibm.com/developerworks/cn/webservices/ws-jaxm/part1/index.html</p>
<li>
<p>        <b></p>
<p>          <a href="http://www.ibm.com/developerworks/cn/xml/tips/x-jaxmsoap/index.html">技巧：用 JAXM 发送和接收 SOAP 消息</a></p>
<p>        </b></p>
<p>本文向您演示如何使用用于 XML 消息传递的 Java API（Java API for XML Messaging (JAXM)）简化创建和发送 SOAP 消息的过程。http://www.ibm.com/developerworks/cn/xml/tips/x-jaxmsoap/index.html</p>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.chenyq.com/archives/6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>今天安装了wordpress</title>
		<link>http://www.chenyq.com/archives/5</link>
		<comments>http://www.chenyq.com/archives/5#comments</comments>
		<pubDate>Wed, 02 May 2007 02:57:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[????]]></category>

		<guid isPermaLink="false">http://www.chenyq.com/archives/5</guid>
		<description><![CDATA[安装了wordpress！]]></description>
			<content:encoded><![CDATA[<p>一直想写blog，由于时间上比较忙，没有动手。51在家，没有太多的事，就安装了这个blog，版本是2.1。<br />
安装中出现了一点小问题，记录在下。<br />
1、默认下载（http://wordpress.org/download/）的wordpress没有中文语言包。google了一下，找到zh_CN.mo。<br />
# 在WordPress安装目录中的wp-content目录下新建languages目录。<br />
# 将zh_CN.mo文件上传到wp-content/languages目录下。<br />
注意：旧版WordPress的语言包要求存放在wp-includes/languages目录，但是从WordPress 2.1开始，WordPress开始使用wp-content/languages目录，但是原有的目录依然可以使用。未来WordPress可能取消对旧版目录的支持，所以请WordPress 2.1以后版本用户尽量将中文包存放在wp-content/languages目录下。<br />
编辑WordPress安装目录中的wp-config.php文件，找到<br />
<strong>define (&#8216;WPLANG&#8217;, &#8221;);</strong><br />
这一行，将其修改为：<br />
<strong>define (&#8216;WPLANG&#8217;, &#8216;zh_CN&#8217;);</strong><br />
2、安装完成后，登陆出现 Warning: Invalid argument supplied for foreach() in capabilities.php<br />
，这个问题主要由于mysql数据库编码引起。<br />
打开 wp-includes/wp-db.php 文件，搜索： $this->select($dbname);<br />
在上面添加一行：</p>
<p>$this->query(&#8220;SET NAMES &#8216;utf8&#8242;&#8221;);</p>
<p>然后重新安装即可 。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chenyq.com/archives/5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

