﻿<?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-内蒙古计算机研究中心java组</title><link>http://free-j2ee.blogjava.net/</link><description>学习，交流j2se,j2ee及中间件的开发。</description><language>zh-cn</language><lastBuildDate>Mon, 15 Jun 2026 09:28:53 GMT</lastBuildDate><pubDate>Mon, 15 Jun 2026 09:28:53 GMT</pubDate><ttl>60</ttl><item><title> JDK1.5 JDK1.6 JDK1.7 帮助文档全系列下载</title><link>http://www.blogjava.net/gdws/archive/2013/10/09/404775.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 09 Oct 2013 01:31:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2013/10/09/404775.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要:  JDK1.5 JDK1.6 JDK1.7 帮助文档全系列下载&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2013/10/09/404775.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/404775.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2013-10-09 09:31 <a href="http://www.blogjava.net/gdws/archive/2013/10/09/404775.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>五种JSP页面跳转方法详解 [转]</title><link>http://www.blogjava.net/gdws/archive/2012/11/13/391273.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Tue, 13 Nov 2012 14:43:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2012/11/13/391273.html</guid><description><![CDATA[<p><strong><u>1. RequestDispatcher.forward()</u></strong></p>
<p>是在<a class="channel_keylink" href="http://server.chinaitlab.com/" target="_blank">服务器</a>端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet or JSP到另外一个Servlet,JSP 或普通HTML文件,也即你的form提交至a.jsp,在a.jsp用到了forward()重定向至b.jsp,此时form提交的所有信息在 b.jsp都可以获得,参数自动传递. 但forward()无法重定向至有frame的jsp文件,可以重定向至有frame的html文件,同时forward()无法在后面带参数传递,比如servlet?name=frank,这样不行,可以程序内通过response.setAttribute("name",name)来传至下一个页面。</p>
<p>重定向后浏览器地址栏URL不变。</p>
<p>例：在servlet中进行重定向</p><pre>public void doPost(HttpServletRequest request,HttpServletResponse response) <br />throws ServletException,IOException{　 response.setContentType("text/html; charset=gb2312");　 ServletContext sc = getServletContext();　 RequestDispatcher rd = null;　 rd = sc.getRequestDispatcher("/index.jsp"); //定向的页面　 rd.forward(request, response);}</pre>
<p>通常在servlet中使用，不在jsp中使用。</p>
<p><u><strong>2. response.sendRedirect()</strong></u></p>
<p>是在用户的浏览器端工作,sendRedirect()可以带参数传递,比如servlet?name=frank传至下个页面,同时它可以重定向至不同的主机上,sendRedirect()可以重定向有frame.的jsp文件.</p>
<p>重定向后在浏览器地址栏上会出现重定向页面的URL</p>
<p>例：在servlet中重定向</p>
<p><pre>public void doPost(HttpServletRequest request,HttpServletResponse response)</pre><pre>throws ServletException,IOException</pre><pre>{</pre><pre>　 response.setContentType("text/html; charset=gb2312");</pre><pre>　 response.sendRedirect("/index.jsp");</pre><pre>}</pre>
<p>&nbsp;</p>
<p>由于response是jsp页面中的隐含对象，故在jsp页面中可以用response.sendRedirect()直接实现重定位。</p>
<p><strong>注意：</strong></p>
<p>(1) 使用response.sendRedirect时，前面不能有HTML输出；</p>
<p>这并不是绝对的，不能有HTML输出其实是指不能有HTML被送到了浏览器。事实上现在的server都有cache机制，一般在8K（我是说 JSP　SERVER），这就意味着，除非你关闭了cache，或者你使用了out.flush()强制刷新，那么在使用sendRedirect之前，有少量的HTML输出也是允许的。</p>
<p>(2) response.sendRedirect之后，应该紧跟一句return。</p>
<p>我们已经知道response.sendRedirect是通过浏览器来做转向的，所以只有在页面处理完成后，才会有实际的动作。既然你已经要做转向了，那么后的输出还有什么意义呢？而且有可能会因为后面的输出导致转向失败。</p>
<p><strong>比较：</strong></p>
<p>(1) Dispatcher.forward()是容器中控制权的转向，在客户端浏览器地址栏中不会显示出转向后的地址；</p>
<p>(2) response.sendRedirect()则是完全的跳转，浏览器将会得到跳转的地址，并重新发送请求链接。这样，从浏览器的地址栏中可以看到跳转后的链接地址。</p>
<p>前者更加高效，在前者可以满足需要时，尽量使用RequestDispatcher.forward()方法。</p>
<p><em>注：在有些情况下，比如，需要跳转到一个其它<a class="channel_keylink" href="http://server.chinaitlab.com/" target="_blank">服务器</a>上的资源，则必须使用HttpServletResponse.sendRequest()方法。</em></p><img src ="http://free-j2ee.blogjava.net/aggbug/391273.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2012-11-13 22:43 <a href="http://www.blogjava.net/gdws/archive/2012/11/13/391273.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Autodesk.MapGuide.Studio.2009错误？</title><link>http://www.blogjava.net/gdws/archive/2011/04/14/348308.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Thu, 14 Apr 2011 10:14:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2011/04/14/348308.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Autodesk.MapGuide.Studio.2009错误&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2011/04/14/348308.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/348308.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2011-04-14 18:14 <a href="http://www.blogjava.net/gdws/archive/2011/04/14/348308.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图解安装Autodesk Infrastructure Map Server(AIMS) 2012</title><link>http://www.blogjava.net/gdws/archive/2011/04/13/348207.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 13 Apr 2011 08:46:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2011/04/13/348207.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 图解安装Autodesk Infrastructure Map Server(AIMS) 2012&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2011/04/13/348207.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/348207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2011-04-13 16:46 <a href="http://www.blogjava.net/gdws/archive/2011/04/13/348207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决QQ和360软件冲突的办法</title><link>http://www.blogjava.net/gdws/archive/2010/11/04/337185.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 03 Nov 2010 17:18:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/11/04/337185.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 解决QQ和360软件冲突的办法&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/11/04/337185.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/337185.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-11-04 01:18 <a href="http://www.blogjava.net/gdws/archive/2010/11/04/337185.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA把各种数据结构转换为JSON格式</title><link>http://www.blogjava.net/gdws/archive/2010/09/15/332071.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 15 Sep 2010 07:10:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/09/15/332071.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 各种数据结构转换为JSON格式&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/09/15/332071.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/332071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-09-15 15:10 <a href="http://www.blogjava.net/gdws/archive/2010/09/15/332071.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse  注册码</title><link>http://www.blogjava.net/gdws/archive/2010/08/22/329606.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Sun, 22 Aug 2010 15:48:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/08/22/329606.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MyEclipse  系列注册码&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/08/22/329606.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/329606.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-08-22 23:48 <a href="http://www.blogjava.net/gdws/archive/2010/08/22/329606.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse注册码及官方下载地址</title><link>http://www.blogjava.net/gdws/archive/2010/08/22/329605.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Sun, 22 Aug 2010 15:44:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/08/22/329605.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: MyEclipse注册码及官方下载地址&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/08/22/329605.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/329605.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-08-22 23:44 <a href="http://www.blogjava.net/gdws/archive/2010/08/22/329605.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MapGuide for java WebGIS的开发</title><link>http://www.blogjava.net/gdws/articles/328292.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Mon, 09 Aug 2010 02:55:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/328292.html</guid><description><![CDATA[
		<p>首先说说环境的安装：<br /><br />1. 下载 MapGuide Server 和 MapGuide Web Server Extensions. 到下载页面下载并安装 MgServerSetup-2.0.x.exe 和 MgWebServerExtensionsSetup-2.0.x.exe （<a href="https://mapguide.osgeo.org/download/releases/2.0.0"><font color="#108ac6">https://mapguide.osgeo.org/download/releases/2.0.0</font></a> ）<br /><br />2. 下载 java viewersample-2.0.zip. 解压到 C:\Program Files\MapGuideOpenSource2.0\WebServerExtensions\www.<br /><br />    注意，解压后，www文件夹下，要有个名叫javav iewersample 的文件夹。改文件夹下，有个readme.Txt，请按上面的说明，进行配置。<br /><br />    在Apach的目录下面找到conf/httped的文件打开后在文件后面添加：<br /><br />    JkMount /mapguide/javaviewersample/* worker1<br /><br />安装数据发布工具Meastro开源的工具。<br /><br /><br />3. 下载示例数据<br /><br />到下载页面，下载 Sheboygan.mgp （注意，下载后，后缀可能是zip，将其改成mgp） 拷贝该文件到 C:\ProgramFiles\MapGuideOpenSource2.0\Server\Packages. 目录下。<br /><br />4. 打开一个浏览器，输入 <a href="http://localhost:8008/mapguide/mapadmin/login.php"><font color="#108ac6">http://localhost:8008/mapguide/mapadmin/login.php</font></a>  .使用站点管理程序 ，装载示例数据，登陆用户名是 "Administrator" ，密码是 "admin". 管理页面出来后，在左侧的导航条，选择 "Load Packages" . 然后选中靠近 Sheboygan.Mgp 的单选按钮，点击 "Load Package".<br /><br />5. 启动示例程序<br /><br />在浏览器中输入 <a href="http://localhost:8008/mapguide/javaviewersample/ajaxtiledviewersample.jsp"><font color="#108ac6">http://localhost:8008/mapguide/javaviewersample/ajaxtiledviewersample.jsp</font></a> , 将会看到运行效果，到此， MapGuide Open Source 就被运行起来了。<br /><br />注：默认的方式是apache+tomcat通过jk的方式配合，其实是可以直接访问tomcat的8080端口。主要需要了解 C:\Program Files\MapGuideOpenSource2.0\WebServerExtensions?\www\WEB-INF\lib下的MapGuideApi.jar。然后看看javaviewersample下的示例程序。<br /><br /><font color="#ff0033">注意：<br /><br />如果这样配置的话，在访问页面的时候会报错：MapGuideJavaApi.dll等路径找不到等等的错误，还有ace失败等错误。<br /><br />这个时候需要把bin目录下面的ace，xenroll.dll文件拷贝到系统的system32下面，先把以前的文件重命名或备份下以免发生错误。<br /><br />然后重启动服务即可，可以看到你的地图了</font>。<br /><br /><br />下篇继续maestro的发布工具介绍......</p>
<img src ="http://free-j2ee.blogjava.net/aggbug/328292.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-08-09 10:55 <a href="http://www.blogjava.net/gdws/articles/328292.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>liferay portal中卸载portlet</title><link>http://www.blogjava.net/liuyimx/archive/2010/07/07/325478.html</link><dc:creator>liuyimx</dc:creator><author>liuyimx</author><pubDate>Wed, 07 Jul 2010 09:16:00 GMT</pubDate><guid>http://www.blogjava.net/liuyimx/archive/2010/07/07/325478.html</guid><description><![CDATA[<h5><strong>一、准备：</strong></h5> <p>我本机的环境是liferay-portal-tomcat-6&nbsp; RC2</p> <p>使用liferay-plugins-sdk开发了一个测试portlet：LiuYiTest</p> <p>将此portlet部署到portal中之后，能够正常显示，没有任何错误信息。页面显示如下：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image_thumb_3.png" width="661" height="67"></a> </p> <h5><strong>二、portal启动状态时undeploy portlet 的操作步骤：</strong></h5> <p>在liferay-portal服务器启动状态下(在liferay-portal服务器启动状态下，这个很重要，后文会讲portal关闭状态下删除文件夹之后的状况)，</p> <p>undeploy这个portlet需要做的事情共有以下几步：</p> <p>1.&nbsp; 在这个portlet右上角点击关闭按钮，关闭这个portlet，这样在卸载了这个portlet之后，再次访问这个页面的时候，不会报portlet找不到的异常</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image_thumb_1.png" width="193" height="69"></a></p> <p>2.&nbsp;&nbsp; 在$LIFERAY_HOME（代表portal的安装路径）中，进入tomcat-$version\webapps，找到我们刚才关闭的LiuYiTest-portlet。</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; 我本机的路径截图如下：</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/liuyimx/WindowsLiveWriter/liferayportalportlet_8D7F/image7_thumb.png" width="931" height="95"></a> </p> <p>&nbsp;&nbsp;&nbsp; 直接移除此portlet文件夹。</p> <p>&nbsp;&nbsp;&nbsp; 删除此文件夹之后，在控制台会输出如下提示：</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 748px; padding-right: 5px; height: 112px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">14:39:11,343 INFO  [ExtHotDeployListener:207] Extension environment <span style="color: #0000ff">for</span> LiuYiTest-portlet will not be undeployed
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">14:39:11,343 INFO  [PortletHotDeployListener:403] Unregistering portlets <span style="color: #0000ff">for</span> LiuYiTest-portlet
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">14:39:11,343 INFO  [PortletHotDeployListener:439] 2 portlets <span style="color: #0000ff">for</span> LiuYiTest-portlet was unregistered
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">14:39:11,406 WARN  [PortletContextListener:86] Unable to dynamically unbind the Liferay data source: Name java_liferay:jdbc is not bound in <span style="color: #0000ff">this</span> Context
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre></pre>
<p>&nbsp;&nbsp;&nbsp; 以上信息的意思总共有以下几点：</p>
<p>&nbsp;&nbsp; 1) 当前卸载的这个portlet的扩展环境将不会被删除，例如当前卸载的portlet用到的全局图片资源，js资源，css资源，其他不在当前portlet文件夹中的 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 相关资源都不会被卸载(删除)。<font color="#000080"><em>%大概是这个意思，可能还有其他更深的意思%</em></font></p>
<p>&nbsp;&nbsp; 2) 这个portlet在portal中的注册信息已经被卸载掉了 </p>
<p>&nbsp;&nbsp; 3) 2个portlet被卸载了 <font color="#000080"><em>%由于我的这个portlet工程(LiuYiTest-portlet)中包含两个具体的portlet，所以是2个portlet被卸载%</em></font> </p>
<p>&nbsp;&nbsp; 4) 最后这句的意思是无法动态的解除绑定的liferay数据资源，冒号后面的信息是提示在卸载的这个portlet内容中没有绑定的数据库内容。 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; <font color="#000080"><em>%liferay-portal会自动删除存在于\tomcat-6.0.26\work\Catalina\localhost目录下以及\tomcat-6.0.26\temp\下的与当前</em></font></p>
<p><font color="#000080"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; portlet有关的一些_jsp.class和资源文件%</em></font></p>
<p>&nbsp;</p>
<p>如果你在删除之前没有首先关闭掉portal页面上的portlet的话，刷心页面之后，控制台会报类似如下错误：</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 900px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">java.lang.NullPointerException
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:122)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:38)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(Unknown Source)</pre></pre><pre class="java:nogutter:nocontrols:collapse" name="code">portlet页面内容中也会有相应提示，这时候只需要在portal中关闭报错的portlet就可以了。<br>
</pre>
<p>3.&nbsp; 如果你的portlet中用到了数据库中的信息，那么需要手动清除一下无用的数据</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 至此为止，部署在liferay-portal中的某个portlet就被成功删除掉了，注意，以上是在liferay-portal启动的情况下的undeploy操作。</p>
<p>&nbsp;</p>
<h5></h5>
<h5><strong>三、portal没有启动状态，undeploy portlet的操作：</strong></h5>
<p>下文是另一种情况：当liferay-portal没有启动的时候，如果直接删除掉了tomcat\webapps下的portlet工程，启动portal的时候会有</p>
<p>如下类似异常报出：</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 900px; padding-right: 5px; height: 300px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.startup.HostConfig deployDescriptor
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">信息: Deploying configuration descriptor 123-portlet.xml
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.startup.ExpandWar copy
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">严重: Error copying D:\worksoft\liferay-portal-6.0.2\tomcat-6.0.26\webapps\123-portlet to D:\worksoft\liferay-portal-6.0.2\tomcat-6.0.26\temp\0-123-portlet
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">java.io.FileNotFoundException: D:\worksoft\liferay-portal-6.0.2\tomcat-6.0.26\webapps\123-portlet (系统找不到指定的文件。)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at java.io.FileInputStream.open(Native Method)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:106)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.ExpandWar.copy(ExpandWar.java:308)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.ContextConfig.antiLocking(ContextConfig.java:984)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:1032)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:263)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4234)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardService.start(StandardService.java:519)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at java.lang.reflect.Method.invoke(Method.java:597)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.core.StandardContext resourcesStart
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">严重: Error starting <span style="color: #0000ff">static</span> Resources
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">java.lang.IllegalArgumentException: Document base D:\worksoft\liferay-portal-6.0.2\tomcat-6.0.26\webapps\123-portlet does not exist or is not a readable directory
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4086)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4255)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardService.start(StandardService.java:519)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at java.lang.reflect.Method.invoke(Method.java:597)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.core.StandardContext start
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">严重: Error in resourceStart()
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.core.StandardContext start
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">严重: Error getConfigured
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2010-7-7 16:21:41 org.apache.catalina.core.StandardContext start
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">严重: Context [/123-portlet] startup failed due to previous errors</pre></pre>
<p>&nbsp;</p>
<p>异常是由于没有清理干净当前portlet相关信息导致的。这个时候需要手动清理。</p>
<p>加上最开始删除的webapps下的portlet这一步(也就是以下的第一步)，在portal没有启动的状态下，undeploy一个portlet的操作步骤如下：</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 1) tomcat-$version\webapps\$portlet_name文件夹(如果) </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 2) tomcat-$version\temp\$portlet_name文件夹 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 3) tomcat-$version\conf\Catalina\localhost\$portlet_name.xml </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 4) 此portlet相关数据库中信息 </p>
<p>其中$version等代表具体的版本和portlet名称。</p>
<p>重新启动portal。至此，没有启动portal的情况下，undeploy portlet的所有操作执行完毕。</p>
<h5><strong>四、最后：</strong></h5>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 以上演示的实例是在liferay-portal-tomcat-6.0.2的liferay portal版本环境下。绑定的tomcat是6.0.26。通过网上资料我了解到似乎不能</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在liferay+jboss的绑定环境下复制以上同样的操作。具体的环境情况下可能有不同的操作方法。</p><img src ="http://free-j2ee.blogjava.net/aggbug/325478.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyimx/" target="_blank">liuyimx</a> 2010-07-07 17:16 <a href="http://www.blogjava.net/liuyimx/archive/2010/07/07/325478.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcate 服务下播放flash问题？【急】</title><link>http://www.blogjava.net/gdws/archive/2010/06/12/323414.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Sat, 12 Jun 2010 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/06/12/323414.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: tomcate 服务下播放flash问题？【急】&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/06/12/323414.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/323414.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-06-12 11:30 <a href="http://www.blogjava.net/gdws/archive/2010/06/12/323414.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java数组排序Arrays.sort，以及Comparator接口的用法</title><link>http://www.blogjava.net/gdws/articles/321391.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 19 May 2010 09:17:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/321391.html</guid><description><![CDATA[
		<p>有的时候需要对数组里的element进行排序。当然可以自己编写合适的排序方法，但既然java包里有自带的Arrays.sort排序方法，在数组元素比较少的时候为何不用？</p>
		<p>　　Sorting an Array 1. 数字排序  int[] intArray = new int[] { 4, 1, 3, -23 };</p>
		<p>　　Arrays.sort(intArray);</p>
		<p>　　输出： [-23, 1, 3, 4]</p>
		<p>　　2. 字符串排序，先大写后小写 String[] strArray = new String[] { "z", "a", "C" };</p>
		<p>　　Arrays.sort(strArray);</p>
		<p>　　输出： [C, a, z]</p>
		<p>　　3. 严格按字母表顺序排序，也就是忽略大小写排序 Case-insensitive sort</p>
		<p>　　Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);</p>
		<p>　　输出： [a, C, z]</p>
		<p>　　4. 反向排序， Reverse-order sort</p>
		<p>　　Arrays.sort(strArray, Collections.reverseOrder());</p>
		<p>　　输出：[z, a, C]</p>
		<p>　　5. 忽略大小写反向排序 Case-insensitive reverse-order sort</p>
		<p>　　Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER);</p>
		<p>　　Collections.reverse(Arrays.asList(strArray));</p>
		<p>　　输出： [z, C, a]</p>
		<p>　　java初学者最常见的错误思想，就是试图去写一些方法来完成数组的排序功能，其实，数组排序功能，在java的api里面早已实现，我们没有必要去重复制造轮子。</p>
		<p>　　Arrays类有一个静态方法sort,利用这个方法我们可以传入我们要排序的数组进去排序，因为我们传入的是一个数组的引用，所以排序完成的结果也通过这个引用的来更改数组.对于整数、字符串排序，jdk提供了默认的实现，如果要对一个对象数组排序，则要自己实现java.util.Comparator接口。</p>
		<p>　　package demo1.client;</p>
		<p>　　import java.util.Arrays;</p>
		<p>　　import java.util.Comparator;</p>
		<p>　　public class ArraySortDemo {</p>
		<p>　　public void sortIntArray() {</p>
		<p>　　int[] arrayToSort = new int[] { 48, 5, 89, 80, 81, 23, 45, 16, 2 };</p>
		<p>　　System.out.println("排序前");</p>
		<p>　　for (int i = 0; i &lt; arrayToSort.length; i++)</p>
		<p>　　System.out.println(arrayToSort[i]);</p>
		<p>　　// 调用数组的静态排序方法sort</p>
		<p>　　Arrays.sort(arrayToSort);</p>
		<p>　　System.out.println("排序后");</p>
		<p>　　for (int i = 0; i &lt; arrayToSort.length; i++)</p>
		<p>　　System.out.println(arrayToSort[i]);</p>
		<p>　　}</p>
		<p>　　public void sortStringArray() {</p>
		<p>　　String[] arrayToSort = new String[] { "Oscar", "Charlie", "Ryan",</p>
		<p>　　"Adam", "David" };</p>
		<p>　　System.out.println("排序前");</p>
		<p>　　for (int i = 0; i &lt; arrayToSort.length; i++)</p>
		<p>　　System.out.println(arrayToSort[i]);</p>
		<p>　　System.out.println("排序后");</p>
		<p>　　//调用数组的静态排序方法sort</p>
		<p>　　Arrays.sort(arrayToSort);</p>
		<p>　　for (int i = 0; i &lt; arrayToSort.length; i++)</p>
		<p>　　System.out.println(arrayToSort[i]);</p>
		<p>　　}</p>
		<p>　　public void sortObjectArray() {</p>
		<p>　　Dog o1 = new Dog("dog1", 1);</p>
		<p>　　Dog o2 = new Dog("dog2", 4);</p>
		<p>　　Dog o3 = new Dog("dog3", 5);</p>
		<p>　　Dog o4 = new Dog("dog4", 2);</p>
		<p>　　Dog o5 = new Dog("dog5", 3);</p>
		<p>　　Dog[] dogs = new Dog[] { o1, o2, o3, o4, o5 };</p>
		<p>　　System.out.println("排序前");</p>
		<p>　　for (int i = 0; i &lt; dogs.length; i++) {</p>
		<p>　　Dog dog = dogs[i];</p>
		<p>　　System.out.println(dog.getName());</p>
		<p>　　}</p>
		<p>　　Arrays.sort(dogs, new ByWeightComparator());</p>
		<p>　　System.out.println("排序后：");</p>
		<p>　　for (int i = 0; i &lt; dogs.length; i++) {</p>
		<p>　　Dog dog = dogs[i];</p>
		<p>　　System.out.println(dog.getName());</p>
		<p>　　}</p>
		<p>　　}</p>
		<p>　　public static void main(String[] args) {</p>
		<p>　　ArraySortDemo t = new ArraySortDemo();</p>
		<p>　　t.sortIntArray();</p>
		<p>　　t.sortStringArray();</p>
		<p>　　t.sortObjectArray();</p>
		<p>　　}</p>
		<p>　　}</p>
		<p>　　class Dog {</p>
		<p>　　private String name;</p>
		<p>　　private int weight;</p>
		<p>　　public Dog(String name, int weight) {</p>
		<p>　　this.setName(name);</p>
		<p>　　this.weight = weight;</p>
		<p>　　}</p>
		<p>　　public int getWeight() {</p>
		<p>　　return weight;</p>
		<p>　　}</p>
		<p>　　public void setWeight(int weight) {</p>
		<p>　　this.weight = weight;</p>
		<p>　　}</p>
		<p>　　public void setName(String name) {</p>
		<p>　　this.name = name;</p>
		<p>　　}</p>
		<p>　　public String getName() {</p>
		<p>　　return name;</p>
		<p>　　}</p>
		<p>　　}</p>
		<p>　　class ByWeightComparator implements Comparator {</p>
		<p>　　public final int compare(Object pFirst, Object pSecond) {</p>
		<p>　　int aFirstWeight = ((Dog) pFirst).getWeight();</p>
		<p>　　int aSecondWeight = ((Dog) pSecond).getWeight();</p>
		<p>　　int diff = aFirstWeight - aSecondWeight;</p>
		<p>　　if (diff &gt; 0)</p>
		<p>　　return 1;</p>
		<p>　　if (diff &lt; 0)</p>
		<p>　　return -1;</p>
		<p>　　else</p>
		<p>　　return 0;</p>
		<p>　　}</p>
		<p>　　}</p>
<img src ="http://free-j2ee.blogjava.net/aggbug/321391.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-05-19 17:17 <a href="http://www.blogjava.net/gdws/articles/321391.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Servlet和JSP经验总结</title><link>http://www.blogjava.net/gdws/articles/321390.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 19 May 2010 09:00:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/321390.html</guid><description><![CDATA[在servlet的init()方法中缓存数据
<p>　　当应用服务器初始化Servlet和JSP实例之后，为客户端请求提供服务之前，它会调用这个servlet的init()方法。在一个servlet的生命周期中，init()方法只会被调用一次。通过在init()方法中缓存一些静态的数据或完成一些只需要执行一次的、耗时的操作，就可大大地提高系统性能。</p><p>　　例如，通过在init()方法中建立一个JDBC连接池是一个最佳例子，假设我们是用jdbc2.0的DataSource接口来取得数据库连接，在通常的情况下，我们需要通过JNDI来取得具体的数据源。我们可以想象在一个具体的应用中，如果每次SQL请求都要执行一次JNDI查询的话，那系统性能将会急剧下降。解决方法是如下代码，它通过缓存DataSource，使得下一次SQL调用时仍然可以继续利用它</p><p>　　1.publicclassControllerServletextendsHttpServlet{</p><p>　　2.privatejavax.sql.DataSourcetestDS=null;</p><p>　　3.publicvoidinit(ServletConfigconfig)throwsServletException{</p><p>　　4.super.init(config);</p><p>　　5.Contextctx=null;</p><p>　　6.try{ctx=newInitialContext();</p><p>　　7.testDS=(javax.sql.DataSource)ctx.lookup("jdbc/testDS");</p><p>　　8.}</p><p>　　9.catch(NamingExceptionne){</p><p>　　10.ne.printStackTrace();</p><p>　　11.}</p><p>　　12.catch(Exceptione){</p><p>　　13.e.printStackTrace();</p><p>　　14.}</p><p>　　15.}</p><p>　　16.publicjavax.sql.DataSourcegetTestDS(){</p><p>　　17.returntestDS;</p><p>　　18.}</p><p>　　19.......</p><p>　　20.}</p><p>　　禁止Servlet和JSP自动重载(auto-reloading)</p><p>　　Servlet和JSP提供了一个实用的技术，即自动重载技术，它为开发人员提供了一个好的开发环境，当你改变servlet和JSP页面后而不必重启应用服务器。然而，这种技术在产品运行阶段对系统的资源是一个极大的损耗，因为它会给JSP引擎的类装载器(classloader)带来极大的负担。因此关闭自动重载功能对系统性能的提升是一个极大的帮助。</p><p>　　不要滥用HttpSession</p><p>　　在很多应用中，我们的程序需要保持客户端的状态，以便页面之间可以相互联系。但不幸的是由于HTTP具有天生无状态性，从而无法保存客户端的状态。因此一般的应用服务器都提供了session来保存客户的状态。在JSP应用服务器中，是通过HttpSession对像来实现session的功能的，但在方便的同时，它也给系统带来了不小的负担。因为每当你获得或更新session时，系统者要对它进行费时的序列化操作。你可以通过对 HttpSession的以下几种处理方式来提升系统的性能：</p><p>　　如果没有必要，就应该关闭JSP页面中对HttpSession的缺省设置：如果你没有明确指定的话，每个JSP页面都会缺省地创建一个HttpSession。如果你的JSP中不需要使用session的话，那可以通过如下的JSP页面指示符来禁止它：</p><p>　　21.＜%@ page session="false"%＞</p><p>　　不要在HttpSession中存放大的数据对像：如果你在HttpSession中存放大的数据对像的话，每当对它进行读写时，应用服务器都将对其进行序列化，从而增加了系统的额外负担。你在HttpSession中存放的数据对像越大，那系统的性能就下降得越快。</p><p>　　当你不需要HttpSession时，尽快地释放它：当你不再需要session时，你可以通过调用HttpSession.invalidate()方法来释放它。</p><p>　　尽量将session的超时时间设得短一点：在JSP应用服务器中，有一个缺省的session的超时时间。当客户在这个时间之后没有进行任何操作的话，系统会将相关的session自动从内存中释放。超时时间设得越大，系统的性能就会越低，因此最好的方法就是尽量使得它的值保持在一个较低的水平。<br /><br /><br />      将页面输出进行压缩</p><p>　　压缩是解决数据冗余的一个好的方法，特别是在网络带宽不够发达的今天。有的浏览器支持gzip(GNU zip)进行来对HTML文件进行压缩，这种方法可以戏剧性地减少HTML文件的<a class="channel_keylink" href="http://download.chinaitlab.com/" target="_blank">下载</a>时间。因此，如果你将servlet或JSP页面生成的HTML页面进行压缩的话，那用户就会觉得页面浏览速度会非常快。但不幸的是，不是所有的浏览器都支持gzip压缩，但你可以通过在你的程序中检查客户的浏览器是否支持它。下面就是关于这种方法实现的一个代码片段：</p><p>　　22.publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)</p><p>　　throwsIOException,ServletException{</p><p>　　23.OutputStreamout=null</p><p>　　24.Stringencoding=request.getHeader("Accept-Encoding");</p><p>　　25.if(encoding!=null&amp;&amp;encoding.indexOf("gzip")!=-1){</p><p>　　26.request.setHeader("Content-Encoding","gzip");</p><p>　　27.out=newGZIPOutputStream(request.getOutputStream());</p><p>　　28.}</p><p>　　29.elseif(encoding!=null&amp;&amp;encoding.indexOf("compress")!=-1){</p><p>　　30.request.setHeader("Content-Encoding","compress");</p><p>　　31.out=newZIPOutputStream(request.getOutputStream());</p><p>　　32.}</p><p>　　33.else{</p><p>　　34.out=request.getOutputStream();</p><p>　　35.}</p><p>　　36.......</p><p>　　37.}</p><p>　　使用线程池</p><p>　　应用服务器缺省地为每个不同的客户端请求创建一个线程进行处理，并为它们分派service()方法，当service()方法调用完成后，与之相应的线程也随之撤消。由于创建和撤消线程会耗费一定的系统资源，这种缺省模式降低了系统的性能。但所幸的是我们可以通过创建一个线程池来改变这种状况。另外，我们还要为这个线程池设置一个最小线程数和一个最大线程数。在应用服务器启动时，它会创建数量等于最小线程数的一个线程池，当客户有请求时，相应地从池从取出一个线程来进行处理，当处理完成后，再将线程重新放入到池中。如果池中的线程不够地话，系统会自动地增加池中线程的数量，但总量不能超过最大线程数。通过使用线程池，当客户端请求急剧增加时，系统的负载就会呈现的平滑的上升曲线，从而提高的系统的可伸缩性。</p><p>　　选择正确的页面包含机制</p><p>　　在JSP中有两种方法可以用来包含另一个页面1、使用include指示符(＜ %@ includee file=”test.jsp” %＞)。2、使用jsp指示符(＜ jsp:includee page=”test.jsp” flush=”true”/＞)。在实际中我发现，如果使用第一种方法的话，可以使得系统性能更高。</p><p>　　正确地确定javabean的生命周期</p><p>　　Servlet和JSP一个强大的地方就是对javabean的支持。通过在JSP页面中使用＜jsp:useBean＞标签，可以将javabean直接插入到一个JSP页面中。它的使用方法如下：</p><p>　　38.＜jsp:useBean id="name" scope="page|request|session|application"</p><p>　　class= "package.className" type="typeName"＞</p><p>　　39.＜/jsp:useBean＞</p><p>　　其中scope属性指出了这个bean的生命周期。缺省的生命周期为page。如果你没有正确地选择bean的生命周期的话，它将影响系统的性能。</p><p>　　举例来说，如果你只想在一次请求中使用某个bean，但你却将这个bean的生命周期设置成了session，那当这次请求结束后，这个bean将仍然保留在内存中，除非session超时或用户关闭浏览器。这样会耗费一定的内存，并无谓的增加了JVM垃圾收集器的工作量。因此为bean设置正确的生命周期，并在bean的使命结束后尽快地清理它们，会使用系统性能有一个提高。</p><p>　　需要注意：</p><p>　　1.在字符串连接操作中尽量不使用“＋”操作符：在java编程中，我们常常使用“＋”操作符来将几个字符串连接起来，但你或许从来没有想到过它居然会对系统性能造成影响吧？由于字符串是常量，因此JVM会产生一些临时的对像。你使用的“＋”越多，生成的临时对像就越多，这样也会给系统性能带来一些影响。解决的方法是用StringBuffer对像来代替“＋”操作符。</p><p>　　2.避免使用System.out.println()方法：由于System.out.println()是一种同步调用，即在调用它时，磁盘I/O操作必须等待它的完成，因此我们要尽量避免对它的调用。但我们在调试程序时它又是一个必不可少的方便工具，为了解决这个矛盾，我建议你最好使用Log4j工具，它既可以方便调试，而不会产生System.out.println()这样的方法。</p><p>　　3.ServletOutputStream 与 PrintWriter的权衡:使用PrintWriter可能会带来一些小的开销，因为它将所有的原始输出都转换为字符流来输出，因此如果使用它来作为页面输出的话，系统要负担一个转换过程。而使用ServletOutputStream作为页面输出的话就不存在一个问题，但它是以二进制进行输出的。</p><img src ="http://free-j2ee.blogjava.net/aggbug/321390.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-05-19 17:00 <a href="http://www.blogjava.net/gdws/articles/321390.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java读取配置文件的几种方法</title><link>http://www.blogjava.net/gdws/archive/2010/05/10/320490.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Mon, 10 May 2010 08:25:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/05/10/320490.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Java读取配置文件&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/05/10/320490.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/320490.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-05-10 16:25 <a href="http://www.blogjava.net/gdws/archive/2010/05/10/320490.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse中配置DWR的简单方法</title><link>http://www.blogjava.net/gdws/archive/2010/05/10/320489.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Mon, 10 May 2010 08:23:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/archive/2010/05/10/320489.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 配置DWR&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/archive/2010/05/10/320489.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/320489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-05-10 16:23 <a href="http://www.blogjava.net/gdws/archive/2010/05/10/320489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP验证码大全之Servlet实现(二) </title><link>http://www.blogjava.net/gdws/articles/319573.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 28 Apr 2010 02:00:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/319573.html</guid><description><![CDATA[
		<font color="#0000ff">
				<strong>Servlet中实现数字英文混合验证码<br /></strong>   以下为在Servlet中产生数字跟英文混合验证码的代码分析。</font>
		<br />    
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><font color="#000080"><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">package org.improviser.validateCode;<br />import javax.imageio.ImageIO; <br />import javax.servlet.http.HttpServlet; <br /><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">import java.awt.Color; <br />import java.awt.Font; <br />import java.awt.Graphics2D; <br />import java.awt.image.BufferedImage; <br />import java.util.Random; <br /></font></span>import javax.servlet.ServletException; <br />import javax.servlet.ServletOutputStream; <br />import javax.servlet.http.HttpServletRequest; <br />import javax.servlet.http.HttpServletResponse; <br />import javax.servlet.http.HttpSession;</font><br /></span></font><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080"><br />public class ValidateCodeServlet extends HttpServlet <br />{<br /></font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080"><br />private int x=0; <br />//设置验证码图片中显示的</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">字体高度</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">private int fontHeight; <br />private int codeY; <br /><br />//在这里定义了<span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">验证码图片的宽度</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">private int width=60; <br />//定义</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">验证码图片的高度。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">private int height=20; <br />//定义</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">验证码字符个数，此处设置为5位</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">private int codeNum=5; </font></span><br /><br />char[] codes = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ,'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',<br />'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',<br />'X', 'Y', 'Z',}; <br /><br />/**<br />* 对</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">验证图片属性进行<span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">初始化</font></span></font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">*/<br />public void init() throws ServletException<br />{<br />//从部署文件web.xml中获取程序初始化信息，图片宽度跟高度，字符个数信息</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080"><br />//获取初始化</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">字符个数</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">String strCodeNums=this.getInitParameter("codeNum"); <br />//获取验证码图片<span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">宽度参数</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">String strW=this.getInitParameter("w"); <br />//获取验证码图片高<span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">度参数</font></span></font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">String strH=this.getInitParameter("h"); </font></span><br /><br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">将配置的字符串信息转换成数值类型数字</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">try<br />{<br />if(strH!=null &amp;&amp; strH.length()!=0)<br />{<br />height=Integer.parseInt(strH); <br />}<br />if(strW!=null &amp;&amp; strW.length()!=0)<br />{<br />width=Integer.parseInt(strW); <br />}<br />if(strCodeNums!=null &amp;&amp; strCodeNums.length()!=0)<br />{<br />codeNum=Integer.parseInt(strCodeNums); <br />}<br />}<br />catch(NumberFormatException e)<br />{}<br /><br />x=width/(codeNum+1); <br />fontHeight=height-2; <br />codeY=height-4; <br /><br />}<br /><br />protected void service(HttpServletRequest req, HttpServletResponse resp)<br />throws ServletException, java.io.IOException<br />{<br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">定义验证码图像的缓冲流</font></span><font color="#000080"><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">BufferedImage buffImg = new BufferedImage(<br />width, height,BufferedImage.TYPE_INT_RGB); <br />//产生图形上下文<br />Graphics2D g = buffImg.createGraphics(); <br /></font></span></font><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">//创建随机数产生函数</font><br /><font color="#000080">Random random = new Random(); <br /><br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">将验证码图像背景填充为白色</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">g.setColor(Color.WHITE); <br />g.fillRect(0, 0, width, height); <br /><br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">创建字体格式，字体的大小则根据验证码图片的高度来设定。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">Font font = new Font("Fixedsys", Font.PLAIN, fontHeight); <br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">设置字体。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">g.setFont(font); <br /><br />//为验证码图片</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">画边框，为一个像素。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">g.setColor(Color.BLACK); <br />g.drawRect(0, 0, width - 1, height - 1); <br /><br />//随机生产222跳图片干扰线条，使验证码图片中的字符不被轻易识别</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">g.setColor(Color.BLACK); <br />for(int i = 0; i </font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">＜</font></span><font color="#000080"><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">222;<font color="#000080"> i++) <br />{<br />int x = random.nextInt(width); <br />int y = random.nextInt(height); <br />int xl = random.nextInt(12); <br />int yl = random.nextInt(12); <br />g.drawLine(x, y, x + xl, y + yl); <br />}</font><br /><br /><font color="#000080">//randomCode保存随机产生的验证码</font></span></font><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">StringBuffer randomCode = new StringBuffer(); <br /><br />//定义颜色三素<br />int red = 0, green = 0, blue = 0; <br /><br />//随机生产codeNum个数字验证码</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">for (int i = 0; i </font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">＜</font></span><font color="#000080"><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"> codeNum; i++) {<br /><font color="#000080">//得到随机产生的验证码<br /></font></span></font><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">String strRand = String.valueOf(codeSequence[random.nextInt(82)]); <br />//使用随机函数</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">产生随机的颜色分量来构造颜色值，这样输出的每位数字的颜色值都将不同。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">red = random.nextInt(255); <br />green = random.nextInt(255); <br />blue = random.nextInt(255); <br /><br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">用随机产生的颜色将验证码绘制到图像中。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">g.setColor(new Color(red, green, blue)); <br />g.drawString(strRand, (i + 1) * x, codeY); <br /><br />//</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">将产生的四个随机数组合在一起。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">randomCode.append(strRand); <br />}<br />// 将生产的验证码保存到Session中</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">HttpSession session = req.getSession(); <br />session.setAttribute("validate", randomCode.toString()); <br /><br />// 设置</font></span><span style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Verdana; mso-hansi-font-family: Verdana; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#000080">图像缓存为no-cache。</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">resp.setHeader("Pragma", "no-cache"); <br />resp.setHeader("Cache-Control", "no-cache"); <br />resp.setDateHeader("Expires", 0); <br /><br />resp.setContentType("image/jpeg"); <br /><br />//将最终生产的验证码图片输出到Servlet的输出流中</font></span><span lang="EN-US" style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><br /><font color="#000080">ServletOutputStream sos = resp.getOutputStream(); <br />ImageIO.write(buffImg, "jpeg", sos); <br />sos.close(); <br />}<br /><br />} </font></span></div> <font color="#0000ff">  以上即是在Servlet中产生英文数字混合验证码的过程，以下介绍下在web.xml中对图片进行部署。<br /><br /><strong>   七、Servlet验证码的部署</strong><br />    在web.xml中声明servlet。</font><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">ValidateCodeServlet</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">org.improviser.<font face="Verdana" color="#000080" size="2">validateCode</font>.ValidateCodeServlet</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">width</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">160</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">height</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">68</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">codeCount</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">5</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">ValidateCodeServlet</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">/validateCodeServlet</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">servlet-mapping</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> <br /></span></div><img src ="http://free-j2ee.blogjava.net/aggbug/319573.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-04-28 10:00 <a href="http://www.blogjava.net/gdws/articles/319573.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP验证码大全之Servlet实现(一)</title><link>http://www.blogjava.net/gdws/articles/319572.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 28 Apr 2010 01:59:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/319572.html</guid><description><![CDATA[
		<font color="#0000ff">         </font>
		<font color="#000000">本文将介绍另一种J2EE中验证码的产生跟使用，即在Servlet中定义验证码的产生并使用，通过将验证码的生成封装到JAVA类中，更好的达到代码跟页面分离的效果，因此提倡使用该方法。<br /><strong>  Servlet中实现四位数字验证码</strong><br />   以下为在Servlet中实现四位数字验证码的源码分析。</font>  
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><p><font color="#000080">import java.awt.image.*;<br />import com.sun.image.codec.jpeg.*;<br />import javax.servlet.*;<br />import javax.servlet.http.*;<br />import java.io.*;<br />import java.util.*;<br />import java.awt.*;<br />/*<br /> * 功能：调用AuthCodeServlet可以生成一个4位数字的验证码图片,验证码的图片宽度和高度可以通过配置文件进行定义<br /> * 验证码调用格式为: /servlet/AuthCodeServlet?w=78&amp;h=32<br /> * 或者使用默认长宽/servlet/AuthCodeServlet<br /> */<br />   public class AuthCodeServlet extends HttpServlet {<br />   // 处理post<br />    public void doPost(HttpServletRequest req,HttpServletResponse res)<br />    throws ServletException,IOException {<br />    doGet(req,res);<br /> }</font></p><p><font color="#000080">   //设置字体<br />   private Font mFont=new Font("Times New Roman", Font.PLAIN,16); </font></p><p><font color="#000080">   public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {</font></p><p><font color="#000080">     HttpSession session=request.getSession();<br />     response.setContentType("image/gif");<br />     response.setHeader("Pragma","No-cache");<br />     response.setHeader("Cache-Control","no-cache");<br />     response.setDateHeader("Expires", 0);<br />     int width=70; //验证码默认长度<br />     int height=24; //验证码默认宽度<br />     if(request.getParameter("w")!=null &amp;&amp; !request.getParameter("w").equals(""))<br />      width = Integer.parseInt(request.getParameter("w"));<br />     if(request.getParameter("h")!=null &amp;&amp; !request.getParameter("h").equals(""))<br />      height = Integer.parseInt(request.getParameter("h"));<br />                 <br />     ServletOutputStream out=response.getOutputStream(); //获取输出流<br />     BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); //新建验证图片，并设置验证码图片的大小<br />     Graphics gra=image.getGraphics(); //获取图形上下文<br />     Random random=new Random();<br />     gra.setColor(getRandColor(260,210));    //设置验证码的图片背景色<br />     gra.fillRect(0,0,width,height);<br />     gra.setColor(Color.BLUE); //设置字体色为蓝色<br />     gra.setFont(mFont); //设置定义的字体格式<br /></font><br /><font color="#000080">     // 随机产生254条干扰直线，使图象中的验证码不易被解析程序分析到<br />     gra.setColor(getRandColor(110,240));<br />     for (int i=0;i&lt;254;i++)<br />     {<br />      int x = random.nextInt(width);<br />      int y = random.nextInt(height);<br />             int xl = random.nextInt(63);<br />             int yl = random.nextInt(64);<br />      gra.drawLine(x,y,x+xl,y+yl);<br />     }</font></p><p><font color="#000080">     // 取随机产生的验证码(4位数字)<br />     String sRand="";<br />     for (int i=0;i&lt;4;i++){<br />     String rand=String.valueOf(random.nextInt(353));<br />     sRand+=rand;<br />     // 将认证码显示到图象中<br />      gra.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));<br />     //调用随机函数构建随机颜色三素<br />         gra.drawString(rand,13*i+6,16);<br />     }<br />         session.setAttribute("authCode",sRand);<br />         JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(out);<br />         encoder.encode(image);</font><br /><font color="#000080"> }</font></p><p><font color="#000080">   static Color getRandColor(int ff,int cc){<br />          //给定范围获得随机颜色<br />          Random random = new Random();<br />          if(fc&gt;255) ff=255;<br />          if(bc&gt;255) cc=255;<br />          int r=ff+random.nextInt(cc-ff);<br />          int g=ff+random.nextInt(cc-ff);<br />          int b=ff+random.nextInt(cc-ff);<br />          return new Color(r,g,b);<br />   }<br />   <br />   static public String getAuthCode(HttpSession session){<br />    //返回验证码<br />    return (String)session.getAttribute("AuthCode");<br />   }<br />}<br /></font></p></div><img src ="http://free-j2ee.blogjava.net/aggbug/319572.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-04-28 09:59 <a href="http://www.blogjava.net/gdws/articles/319572.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP验证码大全之验证码使用与乱码解决[转]</title><link>http://www.blogjava.net/gdws/articles/319571.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 28 Apr 2010 01:57:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/319571.html</guid><description><![CDATA[
		<font color="#0000ff">对验证码的使用分为两个部分，分别为验证码的调用和验证过程，以下分别做说明介绍。<br />   <strong>三、在JSP中调用验证码</strong><br />           使用验证码直接在图片处调用产生验证码的JSP文件即可，同时在刷新验证码按钮处的js代码中使用JSP验证码文件，页面源码如下。</font>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">form </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">id</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"dForm" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">method</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">post </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">action</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"val.jsp"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
										<o:p>
										</o:p>
								</span>
						</p>
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">ul </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">class</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"sFrm"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</p>
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">img </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">id</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"code" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">border</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">0 </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">src</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"Num.jsp"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">/&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">input </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">type</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"button" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">value</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"</span>
								<span style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Courier New'; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">看不清，换一张</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">onClick</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"document.getElementById('code').src='ColorChinese.jsp'"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">div </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">class</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"clear0"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">div</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</p>
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Courier New'; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">验证码</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">input </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">type</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"text" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">name</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"input" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">maxlength</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">8 </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">value</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">""<span style="mso-spacerun: yes">  </span></span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">styleClass</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"sIpt itemFm"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">div </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">class</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"clear0"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">div</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</p>
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">class</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"bar"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">b</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">input </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">type</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"submit" </span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">value</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"</span>
								<span style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-bidi-font-family: 'Courier New'; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">验证测试</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"<span style="mso-spacerun: yes">  </span></span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">styleClass</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"logbtn3"</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">li</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</p>
						<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left">
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">ul</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;<br /></span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;/</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">form</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">
										<span style="mso-spacerun: yes">  </span>
										<o:p>
										</o:p>
								</span>
						</p>
				</span>
				<span style="COLOR: #000000">
						<span style="COLOR: #000000">
						</span>
				</span>
		</div>
		<br />
		<font color="#0000ff">   <strong>四、在JSP中验证码的验证过程以及中文乱码处理</strong><br />            获取用户输入的验证码并与Session中的验证码比较，相同即通过，否则拒绝，对于JSP中中文验证码的处理注意要在页面中定义JSP页面编码跟获取Session的字符编码一致，此处使用的是统一的GB2312编码，否则将出现验证码无法成功验证的情况。</font>
		<br />   
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">val.jsp<br />&lt;%@ </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">page </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">language</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"java" </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">pageEncoding</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"GB2312" %</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&gt;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;%</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">   </span>request.setCharacterEncoding(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"gb2312"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">); <br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">    //获取Session会话中缓存的验证码<br /> </span><span style="mso-tab-count: 1">   </span>String rand = (String)session.getAttribute(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"rand"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">);<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">    //获取用户输入的验证码<br />    String input = request.getParameter(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"input"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">if</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">(rand==</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">null</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">||input==</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">null</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">)</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span>{<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">       //无输入验证码处理代码<br /> </span><span style="mso-tab-count: 1">   </span>}</span><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">  </span><span style="mso-tab-count: 1">  </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">if</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> (rand.equals(input)) {</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">  </span><span style="mso-tab-count: 1">     //验证码对比成功</span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span>}</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span><p></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">else</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span>{<br />       //验证码失败处理代码<br /></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1">   </span>}<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">%&gt;</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">  </span><o:p></o:p></span></p></div><img src ="http://free-j2ee.blogjava.net/aggbug/319571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-04-28 09:57 <a href="http://www.blogjava.net/gdws/articles/319571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP验证码大全之中文验证码[转]</title><link>http://www.blogjava.net/gdws/articles/319570.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 28 Apr 2010 01:56:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/319570.html</guid><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 中文验证码在JSP中的实现，使用中文验证码的好处是能提高验证的有效性，提高验证的安全度，因为中文相对于英文或数字笔画结构相对比较复杂，从而增加了分析程序解析验证码图片并读取验证信息的难度。在文中并分析中文验证的实现过程。   二、JSP中实现中文验证码源码如下：																				ChineseVal.jsp																				&...&nbsp;&nbsp;<a href='http://www.blogjava.net/gdws/articles/319570.html'>阅读全文</a><img src ="http://free-j2ee.blogjava.net/aggbug/319570.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-04-28 09:56 <a href="http://www.blogjava.net/gdws/articles/319570.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP验证码大全之数字验证码[转]</title><link>http://www.blogjava.net/gdws/articles/319569.html</link><dc:creator>帅子</dc:creator><author>帅子</author><pubDate>Wed, 28 Apr 2010 01:54:00 GMT</pubDate><guid>http://www.blogjava.net/gdws/articles/319569.html</guid><description><![CDATA[
		<font color="#0000ff">     </font>
		<font color="#000000">  验证码应用在各种场合中，十分广泛，在多种多样的系统或软件中的新用户帐户注册、用户登录、网站统一登陆或者用户在网站发布信息模块发布文章或内容都添加的随机码功能，对用户操作过程进行一种验证，使用验证码的目的就是为了避免网络中的自动注册程序或者自动发布程序的滥用。 验证码的原理其实就是随机选择一些字符码以将字符码以图片的形式展现在软件验证界面或验证页面上，当用户在进行提交操作的同时需要将图片上的验证码输入并同时提交，如果提交的字符验证码与服务器session保存的字符码相同，则认为提交信息有效，否则拒绝提交。在使用验证码过程中，为了避免自动分析程序解析图片并获得验证信息，通常需要在图片上随机生成一些干扰线或者将复杂的字符对图片进行扭曲模糊，从而增加了自动识别程序分析验证图片的难度。<br />   JSP验证码源码大全将分别用几个篇幅的内容来介绍在JSP中几种验证码的实现源码以及使用。<br />   <strong>一、JSP中产生数字验证码源码</strong>   <br />   数字验证码是一种最常用的验证字符码形式，以下为数字实现的JSP源码：</font>    
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 97.25%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 1162px; BACKGROUND-COLOR: #eeeeee"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">Num.jsp<br />&lt;%@ </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #3f7f7f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">page </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">contentType</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"image/jpeg" </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f007f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">import</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">=</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">%&gt;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;%!</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>Color getRandColor(</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> cc,</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> bb)</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>{</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span>Random random = </span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> Random();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">if</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">(fc&gt;255) cc=255;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">if</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">(bc&gt;255) bb=255;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> r=cc+random.nextInt(bb-cc);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> g=cc+random.nextInt(bb-cc);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> b=cc+random.nextInt(bb-cc);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-spacerun: yes">        </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">return</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> Color(r,g,b);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>} <font color="#800080">//获取随机颜色<br /></font></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">%&gt;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">&lt;%</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>response.setHeader(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"Pragma"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">,</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"No-cache"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>response.setHeader(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"Cache-Control"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">,</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"no-cache"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>response.setDateHeader(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"Expires"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">, 0);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> width=80; <font color="#800080">//定义验证码图片的长度</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> height=30; <font color="#800080">//定义验证码图片的宽度</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>BufferedImage image = </span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>Graphics g = image.getGraphics();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>Random random = </span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> Random();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>g.setColor(getRandColor(200,250));</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>g.fillRect(0, 0, width, height);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>g.setFont(</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> Font(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"Times New Roman"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">,Font.PLAIN,18));<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p>    <font color="#800080">//定义字体形式</font><br /> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>g.setColor(getRandColor(160,200));</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">for</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> (</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i=0;i&lt;155;i++)</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>{</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i_x = random.nextInt(width);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i_y = random.nextInt(height);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i_xl = random.nextInt(12);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i_yl = random.nextInt(12);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span>g.drawLine(i_x,i_y,i_x+i_xl,i_y+i_yl);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>}<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p>    <font color="#800080">//用线条画背景<br /></font> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>String s_Rand=</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">""</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">for</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> (</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">int</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> i=0;i&lt;4;i++)</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>{</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span>String rand=String.valueOf(random.nextInt(10));</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span>s_Rand+=rand;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span>g.setColor(</span><b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">new</span></b><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"> Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 2">       </span>g.drawString(rand,13*i+6,16);</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>}<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p>    <font color="#800080">//产生4位随机码</font> <br /> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>session.setAttribute(</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"rand"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">,s_Rand);<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p>    <font color="#800080">//将验证码存入Session中</font><br /> </o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>g.dispose();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>ImageIO.write(image, </span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">"JPEG"</span><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">, response.getOutputStream());<br /></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    <font color="#800080">//输出验证图片</font><br />    </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>out.clear();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span>out = pageContext.pushBody();</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><span style="mso-tab-count: 1">    </span></span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align="left"><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #bf5f3f; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt">%&gt;</span><span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-font-kerning: 0pt"><o:p></o:p></span></p></div><img src ="http://free-j2ee.blogjava.net/aggbug/319569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/gdws/" target="_blank">帅子</a> 2010-04-28 09:54 <a href="http://www.blogjava.net/gdws/articles/319569.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>