﻿<?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-藏经阁-文章分类-Web服务器</title><link>http://www.blogjava.net/zhouf/category/45695.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 21 Oct 2018 10:54:40 GMT</lastBuildDate><pubDate>Sun, 21 Oct 2018 10:54:40 GMT</pubDate><ttl>60</ttl><item><title>Tomcat配置cgi运行python脚本</title><link>http://www.blogjava.net/zhouf/articles/433448.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Sat, 20 Oct 2018 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/433448.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/433448.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/433448.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/433448.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/433448.html</trackback:ping><description><![CDATA[今天折腾一下如何在Tomcat环境下运行python脚本，查阅了一些文档，把实现的过程小结如下，当前实验环境，Tomcat8，Eclipse。python环境是Anaconda，因为之前有安装这个东东，也就没有重新安装python环境了。首先在Eclipse中创建新工程，并可以在Tomcat中运行起来，接下来才是配置cgi的步骤<br /><br /><div>1、在web工程WEB-INF目录下创建目录cgi，当然也可以是别的名字</div><div></div><div>2、修改web.xml，开启如下设置，默认情况是注释掉的<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">servlet</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">servlet-name</span><span style="color: #0000FF; ">&gt;</span>cgi<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">servlet-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">servlet-class</span><span style="color: #0000FF; ">&gt;</span>org.apache.catalina.servlets.CGIServlet<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">servlet-class</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span>clientinputTimeout<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span>100<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span>debug<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span>0<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span>passShellEnvironment<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span>true<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span>cgiPathPrefix<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span>WEB-INF/cgi<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span>executable<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span>D:/Anaconda3/python.exe<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">param-value</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">init-param</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">load-on-startup</span><span style="color: #0000FF; ">&gt;</span>5<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">load-on-startup</span><span style="color: #0000FF; ">&gt;</span><br /><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">servlet</span><span style="color: #0000FF; ">&gt;</span></div><div>注意修改python的路径</div><div>cgiPathPrefix: 与Server能够访问的脚本目录有关，与之前创建的目录相对应<br /><br /><div>3、开启cgi的mapping映射，修改web.xml，开启如下设置<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">servlet-mapping</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">servlet-name</span><span style="color: #0000FF; ">&gt;</span>cgi<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">servlet-name</span><span style="color: #0000FF; ">&gt;</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">url-pattern</span><span style="color: #0000FF; ">&gt;</span>/cgi-bin/*<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">url-pattern</span><span style="color: #0000FF; ">&gt;</span><br /><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">servlet-mapping</span><span style="color: #0000FF; ">&gt;</span></div></div></div><div>访问路径可以修改为自定义字符<br /><div></div><div>4、修改content.xml文件，在Context中添加privileged属性<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">Context&nbsp;</span><span style="color: #FF0000; ">privileged</span><span style="color: #0000FF; ">="true"</span><span style="color: #0000FF; ">&gt;</span></div><br /><div>5、在工程cgi目录写python文件，如hello.py<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">print</span>(<span style="color: #800000; ">'</span><span style="color: #800000; ">Content-type:&nbsp;text/plain\n\n</span><span style="color: #800000; ">'</span>)<br /><br /><span style="color: #0000FF; ">print</span>(<span style="color: #800000; ">'</span><span style="color: #800000; ">Hello&nbsp;python</span><span style="color: #800000; ">'</span>)</div></div><div>输出text/plain说明这是一个普通文本，一定注意之后要有两个换行（小心坑啦）！！！</div><div><br /><div></div><div>6、运行工程并测试</div><div>http://localhost:8080/prj/cgi-bin/hello.py</div></div></div></div><br />所见结果，通过这种方法可以在Tomcat环境下运行python脚本了，如果是已经用python脚本做好了服务的话，还是可以考虑通过服务调用的方式与Tomcat工程进行整合，在此记录一下</div><img src ="http://www.blogjava.net/zhouf/aggbug/433448.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2018-10-20 10:34 <a href="http://www.blogjava.net/zhouf/articles/433448.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat+Eclipse环境下使用Jenkins2.38搭建持续集成(CI)环境</title><link>http://www.blogjava.net/zhouf/articles/432234.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Mon, 02 Jan 2017 03:51:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/432234.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/432234.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/432234.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/432234.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/432234.html</trackback:ping><description><![CDATA[在网上看到很多关于使用Jenkins构建持续集成环境的文章，在有空的时候也希望尝试一下，这样可以在测试服务器上看到提交的最新版本<br />
<h3>1.下载安装Jenkins</h3>
可以在<a href="http://mirrors.jenkins-ci.org" target="_blank">http://mirrors.jenkins-ci.org</a>上下载安装包，也可以选择在官网（<a href="https://jenkins.io" target="_blank">https://jenkins.io</a>）上下载war包(<a href="http://mirrors.jenkins.io/war-stable/latest/jenkins.war" target="_blank">http://mirrors.jenkins.io/war-stable/latest/jenkins.war</a>)或是安装包(<a href="http://mirrors.jenkins-ci.org/windows/jenkins-2.38.zip" target="_blank">http://mirrors.jenkins-ci.org/windows/jenkins-2.38.zip</a>)，写这篇文章时最新版本为2.38。如果选择安装包方式，下载后安装即可，安装完成后会自动启动浏览器向导，根据提示操作完成安装<br />
本机下载安装包，安装到C:\Jenkins，如下配置也是基于此目录进行，下载及安装过程截图如下<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/download_jenkins.png" width="600" height="333" alt="" /><br />
选择Download Jenkins<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/download.png" width="600" height="447" alt="" /><br />
下拉选择相应的操作系统版本，也可以直接下载war包，本文下载Windows版本的安装包，安装过程指定安装目录即可，安装完成后，会自动启动浏览器进行配置<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/unlock_jenkins.png" width="600" height="564" alt="" /><br />
根据页面提示，在文件中找到密码填入<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/select_plugins.png" width="600" height="564" alt="" /><br />
选择插件，本例选择第二项，自己定义插件，打开第二项里的默认选择和推荐插件一样，如果不做修改，就相当于选择推荐插件安装<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/install_plugins2.png" width="600" height="562" alt="" /><br />
安装完成后，设置管理员账号<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/admin_account.png" width="600" height="566" alt="" /><br />
保存结束安装<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/finish.png" width="600" height="561" alt="" /><br />
点击开始进入Jenkins界面<br />
<img src="http://www.blogjava.net/images/blogjava_net/zhouf/jenkins_index.png" border="0" alt="" /><br />
<h3>2.启动Jenkins</h3>
Jenkins默认工作目录会在当前用户目录下创建.jenkins目录，也可以通过设置环境变量来修改，例如：
<div>set JENKINS_HOME=C:\jenkins</div>
<div>然后重新启动jenkins，可以放在与安装目录不同的地方<br />
进入安装目录C:\Jenkins，用命令行方式启动<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->java&nbsp;-jar&nbsp;jenkins.war</div>
</div>
默认端口为8080，如果需要指定端口，可以使用如下参数指定，如指定端口为9000<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
-->java&nbsp;-jar&nbsp;jenkins.war&nbsp;--httpPort=9000</div>
也可以修改目录下的jenkins.xml配置文件，将其中的httpPort修改即可<br />
<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">arguments</span><span style="color: #0000FF; ">&gt;</span>-Xrs&nbsp;-Xmx256m&nbsp;-Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle&nbsp;-jar&nbsp;"%BASE%\jenkins.war"&nbsp;--httpPort=8080&nbsp;--webroot="%BASE%\war"<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">arguments</span><span style="color: #0000FF; ">&gt;</span></div>
<h3>3.部署应用到Jenkins</h3>
之前的工程是基于Tomcat+Eclipse开发的，工程不是用Maven管理的，后面就对工程进行了改造，用Ant编译，添加了build.xml文件，在Ant中需要找到Tomcat目录，为了灵活一点，在系统里添加了Tomcat的环境变量CATALINA_HOME，以及Ant环境的安装，这是对原有工程的改造，如果新的工程采用Maven方式的话，应该会没有这么麻烦，附上build.xml<br />
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000FF; ">&lt;?</span><span style="color: #FF00FF; ">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"&nbsp;standalone="no"</span><span style="color: #0000FF; ">?&gt;</span><br />
<br />
<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">project&nbsp;</span><span style="color: #FF0000; ">basedir</span><span style="color: #0000FF; ">="."</span><span style="color: #FF0000; ">&nbsp;default</span><span style="color: #0000FF; ">="build"</span><span style="color: #FF0000; ">&nbsp;name</span><span style="color: #0000FF; ">="xi"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">environment</span><span style="color: #0000FF; ">="env"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="tomcat.home"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${env.CATALINA_HOME}"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="tomcat.lib"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${env.CATALINA_HOME}/lib"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="web.root"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${env.CATALINA_HOME}/webapps"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="ant.home"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${env.ANT_HOME}"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="debuglevel"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="source,lines,vars"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="target"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="1.7"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="source"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="1.7"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="webRoot.dir"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${basedir}/WebContent"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="src.dir"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${basedir}/src"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="lib.dir"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${webRoot.dir}/WEB-INF/lib"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="log.file"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="${tomcat.home}/webapps/log.info"</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">tstamp</span><span style="color: #0000FF; ">&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">format&nbsp;</span><span style="color: #FF0000; ">property</span><span style="color: #0000FF; ">="build.time"</span><span style="color: #FF0000; ">&nbsp;pattern</span><span style="color: #0000FF; ">="yyyy-MM-dd&nbsp;HH:mm:ss"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">tstamp</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">path&nbsp;</span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="prj.classpath"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">pathelement&nbsp;</span><span style="color: #FF0000; ">location</span><span style="color: #0000FF; ">="build/classes"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fileset&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${tomcat.lib}"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">include&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="*.jar"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fileset</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fileset&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${lib.dir}"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">include&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="*.jar"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fileset</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">path</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">path&nbsp;</span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="tomcat.classpath"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fileset&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${tomcat.lib}"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">include&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="*.jar"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fileset</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fileset&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${tomcat.home}/bin"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">include&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="*.jar"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fileset</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">path</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="init"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">echo&nbsp;</span><span style="color: #FF0000; ">message</span><span style="color: #0000FF; ">="----------&nbsp;init&nbsp;----------"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">echo</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">mkdir&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="build/classes"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">copy&nbsp;</span><span style="color: #FF0000; ">includeemptydirs</span><span style="color: #0000FF; ">="false"</span><span style="color: #FF0000; ">&nbsp;todir</span><span style="color: #0000FF; ">="build/classes"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">fileset&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="src"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">exclude&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="**/*.java"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">fileset</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">copy</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="clean"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">echo&nbsp;</span><span style="color: #FF0000; ">message</span><span style="color: #0000FF; ">="----------&nbsp;clean&nbsp;----------"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">echo</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="build/classes"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">file</span><span style="color: #0000FF; ">="build/${ant.project.name}.war"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">delete</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="compile"</span><span style="color: #FF0000; ">&nbsp;depends</span><span style="color: #0000FF; ">="init"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">echo&nbsp;</span><span style="color: #FF0000; ">message</span><span style="color: #0000FF; ">="${ant.project.name}:&nbsp;${ant.file}"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">javac&nbsp;</span><span style="color: #FF0000; ">debug</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">&nbsp;debuglevel</span><span style="color: #0000FF; ">="${debuglevel}"</span><span style="color: #FF0000; ">&nbsp;destdir</span><span style="color: #0000FF; ">="build/classes"</span><span style="color: #FF0000; ">&nbsp;includeantruntime</span><span style="color: #0000FF; ">="false"</span><span style="color: #FF0000; ">&nbsp;&nbsp;encoding</span><span style="color: #0000FF; ">="UTF-8"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">src&nbsp;</span><span style="color: #FF0000; ">path</span><span style="color: #0000FF; ">="src"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">classpath&nbsp;</span><span style="color: #FF0000; ">refid</span><span style="color: #0000FF; ">="prj.classpath"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">javac</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">file</span><span style="color: #0000FF; ">="build/classes/gen-conf.xml"</span><span style="color: #0000FF; ">/&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="build"</span><span style="color: #FF0000; ">&nbsp;depends</span><span style="color: #0000FF; ">="compile"</span><span style="color: #FF0000; ">&nbsp;description</span><span style="color: #0000FF; ">="make&nbsp;war"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">war&nbsp;</span><span style="color: #FF0000; ">destfile</span><span style="color: #0000FF; ">="build/${ant.project.name}.war"</span><span style="color: #FF0000; ">&nbsp;basedir</span><span style="color: #0000FF; ">="WebContent"</span><span style="color: #FF0000; ">&nbsp;webxml</span><span style="color: #0000FF; ">="WebContent/WEB-INF/web.xml"</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">&lt;!--</span><span style="color: #008000; ">&nbsp;lib&nbsp;dir="${lib.dir}"&gt;&lt;/lib&nbsp;</span><span style="color: #008000; ">--&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">classes&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${basedir}/build/classes"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">classes</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">war</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="deploy"</span><span style="color: #FF0000; ">&nbsp;depends</span><span style="color: #0000FF; ">="build"</span><span style="color: #FF0000; ">&nbsp;description</span><span style="color: #0000FF; ">="deploy&nbsp;to&nbsp;tomcat"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">echo&nbsp;</span><span style="color: #FF0000; ">message</span><span style="color: #0000FF; ">="----------deploy&nbsp;to&nbsp;tomcat----------"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">echo</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">file</span><span style="color: #0000FF; ">="${tomcat.home}/webapps/${ant.project.name}.war"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${tomcat.home}/webapps/${ant.project.name}"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">copy&nbsp;</span><span style="color: #FF0000; ">file</span><span style="color: #0000FF; ">="build/${ant.project.name}.war"</span><span style="color: #FF0000; ">&nbsp;todir</span><span style="color: #0000FF; ">="${tomcat.home}/webapps"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">target&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="undeploy"</span><span style="color: #FF0000; ">&nbsp;description</span><span style="color: #0000FF; ">="deploy&nbsp;to&nbsp;tomcat"</span><span style="color: #0000FF; ">&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">echo&nbsp;</span><span style="color: #FF0000; ">message</span><span style="color: #0000FF; ">="----------&nbsp;undeploy&nbsp;project&nbsp;----------"</span><span style="color: #0000FF; ">&gt;&lt;/</span><span style="color: #800000; ">echo</span><span style="color: #0000FF; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">file</span><span style="color: #0000FF; ">="${tomcat.home}/webapps/${ant.project.name}.war"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">delete&nbsp;</span><span style="color: #FF0000; ">dir</span><span style="color: #0000FF; ">="${tomcat.home}/webapps/${ant.project.name}"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span>&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">target</span><span style="color: #0000FF; ">&gt;</span>&nbsp;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
<span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">project</span><span style="color: #0000FF; ">&gt;</span></div>
这样写是为了在Jenkins里调用Ant完成编译和部署的工作。<br />
在Jenkins里创建项目，当前选择的是自由项目，写好项目名称，后续就是对项目进行配置，如果不希望保留过多的旧构建，可以设置丢弃。另外还需要获取源码的服务器，默认支持CVS和Subversion，也可以通过插件支持Git，因当前项目托管于SVN，配置如下图<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/job_conf1.png" width="586" height="745" border="1" alt="" style="border-color: #808080;" /><br />
后面是如何触发的配置，如下设置为每天6:30进行构建，每一个小时检查一下源码，主要是获取到代码后的动作设置<br /><img src="http://www.blogjava.net/images/blogjava_net/zhouf/job_conf.png" width="317" height="651" border="1" alt="" style="border-color: #808080;" /><br />
在动作设置里用Windows的批处理方式进行，原本考虑在服务器上做一个批处理，由Jenkins调用，经测试需要用绝对路径，不知是不是某个地方没配置好，后来就改用这种方式，对服务进行启动停止控制，对工程进行部署<br />
经测试，此方式可以用，当前用来解决Tomcat+Eclipse环境下的工程自动构建问题，写在这个地方做个记录，如果有机会，尝试一下Maven，看看是不是要简单点<img src ="http://www.blogjava.net/zhouf/aggbug/432234.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2017-01-02 11:51 <a href="http://www.blogjava.net/zhouf/articles/432234.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将Tomcat8日志配置为log4j日志系统</title><link>http://www.blogjava.net/zhouf/articles/Tomcat8-log4j-config.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Sat, 30 Apr 2016 11:48:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/Tomcat8-log4j-config.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/430314.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/Tomcat8-log4j-config.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/430314.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/430314.html</trackback:ping><description><![CDATA[<div>Tomcat控制台启动日志是由java.util.logging.Logger实现的，我只是希望能自己定义输出格式，找了下文档，发现在%CATALINA_HOME%\conf目录下面有个logging.properties文件，里面有项内容为：</div><div>java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter</div><div>这里的formatter需要通过类来实现，要是能在这里直接写formatter格式字串就好了，继续研究下吧。</div><div><br />电脑上安装的是Tomcat8，找了下官网上的文档，有关于使用Log4j作为日志的配置</div><div>http://tomcat.apache.org/tomcat-8.0-doc/logging.html#Using_Log4j</div><div>就试下了，下面是官网的实现步骤，文中描述的%CATALINA_HOME%是指Tomcat安装目录<br /><br />1. 准备日志配置文件</div><div>官网上有一个配置文件，先拿来用下，后面根据自己的需要再慢慢作调整，保存到%CATALINA_HOME%\lib\log4j.properties<br /><div style="font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all; background-color: #eeeeee;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->log4j.rootLogger=INFO,&nbsp;CATALINA<br /><br />#&nbsp;Define&nbsp;all&nbsp;the&nbsp;appenders<br />log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.<br />log4j.appender.CATALINA.Append=true<br />log4j.appender.CATALINA.Encoding=UTF-8<br />#&nbsp;Roll-over&nbsp;the&nbsp;log&nbsp;once&nbsp;per&nbsp;day<br />log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'<br />log4j.appender.CATALINA.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout<br />log4j.appender.CATALINA.layout.ConversionPattern&nbsp;=&nbsp;%d&nbsp;<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">%t</span><span style="color: #800000; font-weight: bold; ">]</span>&nbsp;%-5p&nbsp;%c-&nbsp;%m%n<br /><br />log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.<br />log4j.appender.LOCALHOST.Append=true<br />log4j.appender.LOCALHOST.Encoding=UTF-8<br />log4j.appender.LOCALHOST.DatePattern='.'yyyy-MM-dd'.log'<br />log4j.appender.LOCALHOST.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout<br />log4j.appender.LOCALHOST.layout.ConversionPattern&nbsp;=&nbsp;%d&nbsp;<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">%t</span><span style="color: #800000; font-weight: bold; ">]</span>&nbsp;%-5p&nbsp;%c-&nbsp;%m%n<br /><br />log4j.appender.MANAGER=org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.MANAGER.File=${catalina.base}/logs/manager.<br />log4j.appender.MANAGER.Append=true<br />log4j.appender.MANAGER.Encoding=UTF-8<br />log4j.appender.MANAGER.DatePattern='.'yyyy-MM-dd'.log'<br />log4j.appender.MANAGER.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout<br />log4j.appender.MANAGER.layout.ConversionPattern&nbsp;=&nbsp;%d&nbsp;<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">%t</span><span style="color: #800000; font-weight: bold; ">]</span>&nbsp;%-5p&nbsp;%c-&nbsp;%m%n<br /><br />log4j.appender.HOST-MANAGER=org.apache.log4j.DailyRollingFileAppender<br />log4j.appender.HOST-MANAGER.File=${catalina.base}/logs/host-manager.<br />log4j.appender.HOST-MANAGER.Append=true<br />log4j.appender.HOST-MANAGER.Encoding=UTF-8<br />log4j.appender.HOST-MANAGER.DatePattern='.'yyyy-MM-dd'.log'<br />log4j.appender.HOST-MANAGER.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout<br />log4j.appender.HOST-MANAGER.layout.ConversionPattern&nbsp;=&nbsp;%d&nbsp;<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">%t</span><span style="color: #800000; font-weight: bold; ">]</span>&nbsp;%-5p&nbsp;%c-&nbsp;%m%n<br /><br />log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender<br />log4j.appender.CONSOLE.Encoding=UTF-8<br />log4j.appender.CONSOLE.layout&nbsp;=&nbsp;org.apache.log4j.PatternLayout<br />log4j.appender.CONSOLE.layout.ConversionPattern&nbsp;=&nbsp;%d&nbsp;<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">%t</span><span style="color: #800000; font-weight: bold; ">]</span>&nbsp;%-5p&nbsp;%c-&nbsp;%m%n<br /><br />#&nbsp;Configure&nbsp;which&nbsp;loggers&nbsp;log&nbsp;to&nbsp;which&nbsp;appenders<br />log4j.logger.org.apache.catalina.core.ContainerBase.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">Catalina</span><span style="color: #800000; font-weight: bold; ">]</span>.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">localhost</span><span style="color: #800000; font-weight: bold; ">]</span>=INFO,&nbsp;LOCALHOST<br />log4j.logger.org.apache.catalina.core.ContainerBase.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">Catalina</span><span style="color: #800000; font-weight: bold; ">]</span>.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">localhost</span><span style="color: #800000; font-weight: bold; ">]</span>.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">/manager</span><span style="color: #800000; font-weight: bold; ">]</span>=INFO,&nbsp;MANAGER<br />log4j.logger.org.apache.catalina.core.ContainerBase.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">Catalina</span><span style="color: #800000; font-weight: bold; ">]</span>.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">localhost</span><span style="color: #800000; font-weight: bold; ">]</span>.<span style="color: #800000; font-weight: bold; ">[</span><span style="color: #800000; ">/host-manager</span><span style="color: #800000; font-weight: bold; ">]</span>=INFO,&nbsp;HOST-MANAGER</div><br /><div>2. 需要下载Log4j的jar包</div><div>1.2的版本下载如下</div><div>http://logging.apache.org/log4j/1.2/download.html</div><div></div><div>3. 下载Tomcat8的扩展组件</div><div>就是在下载Tomcat8的那个页面<a href="http://tomcat.apache.org/download-80.cgi">http://tomcat.apache.org/download-80.cgi</a>，下面点有个Extras，里面有两项<a href="http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.33/bin/extras/tomcat-juli-adapters.jar">JULI adapters jar</a> 和 <a href="http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.33/bin/extras/tomcat-juli.jar">JULI log4j jar</a>的下载，下载后的两个文件为tomcat-juli.jar，tomcat-juli-adapters.jar</div><div></div><div>4. 准备和替换</div><div>把下载的log4j.jar和tomcat-juli-adapters.jar放到%CATALINA_HOME%\lib</div><div>把下载的tomcat-juli.jar替换掉%CATALINA_HOME%\bin\tomcat-juli.jar</div><div></div><div>5. 删除%CATALINA_HOME%\conf\logging.properties文件</div><div></div><div>6. 重新启动Tomcat<br /><hr /><div>上面就是官网给出的操作步骤，结果可行，只是第一次运行时，控制台什么都没有，原来日志配置文件里的</div><div><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->log4j.rootLogger=INFO,&nbsp;CATALINA</div></div><div>就输出到文件里去了，把CONSOLE加上</div><div><div style="font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all; background-color: #eeeeee;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->log4j.rootLogger=INFO,&nbsp;CATALINA,CONSOLE</div></div><div>这里重新启动Tomcat，就可以看到原来的日志信息了。</div><div>到此，将Tomcat配置为log4j日志系统就改造结束了，要实现自己定义日志格式，那就折腾一下这个log4j.properties吧</div></div></div><img src ="http://www.blogjava.net/zhouf/aggbug/430314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2016-04-30 19:48 <a href="http://www.blogjava.net/zhouf/articles/Tomcat8-log4j-config.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Tomcat7中添加外部Context</title><link>http://www.blogjava.net/zhouf/articles/414152.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Tue, 27 May 2014 02:59:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/414152.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/414152.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/414152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/414152.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/414152.html</trackback:ping><description><![CDATA[在网上找了两种方法，分别试了一下<br />其一是修改server.xml，在&lt;Host&gt;标签中添加context配置，如下<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">Context&nbsp;</span><span style="color: #FF0000; ">path</span><span style="color: #0000FF; ">="/book"</span><span style="color: #FF0000; ">&nbsp;docBase</span><span style="color: #0000FF; ">="D:\eclipse\workspace\book\WebRoot"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span></div>另一种是在conf\Catalina\localhost目录下添加配置文件，如prj.xml，内容如下<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">&lt;?</span><span style="color: #FF00FF; ">xml&nbsp;version='1.0'&nbsp;encoding='utf-8'</span><span style="color: #0000FF; ">?&gt;</span><br /><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">Context&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF0000; ">crossContext</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;docBase</span><span style="color: #0000FF; ">="D:\eclipse\workspace\prj\WebRoot"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;path</span><span style="color: #0000FF; ">="/prj"</span><span style="color: #0000FF; ">&gt;</span><br /><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">Context</span><span style="color: #0000FF; ">&gt;</span></div>搞定，第二种的话如果不需要了，直接删除文件就是了，不用修改server.xml配置文件，这个我喜欢。<br />在官网的文档上没找到，还是在网上找的，在些记录一下，以备查<img src ="http://www.blogjava.net/zhouf/aggbug/414152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2014-05-27 10:59 <a href="http://www.blogjava.net/zhouf/articles/414152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决从JBOSS迁移到TOMCAT下的MYSQL乱码问题</title><link>http://www.blogjava.net/zhouf/articles/278085.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Tue, 26 May 2009 13:10:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/278085.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/278085.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/278085.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/278085.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/278085.html</trackback:ping><description><![CDATA[弄了老半天,终于是把这个问题给搞定了,一个在JOBSS下跑得很好的程序,因为某些原因需要迁移到TOMCAT下面,可老是出现乱码的问题,情况如下<br />
数据库:MYSQL5.0<br />
数据库编码:UTF-8<br />
所有页面编码都统一用UTF-8<br />
在JBOSS下配置数据源,即修改mysql-ds.xml<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">app</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc:mysql://localhost/app</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">com.mysql.jdbc.Driver</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">user-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">user</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">user-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">pwd</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">mySQL</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
当把应用迁移到TOMCAT6下时,配置好TOMCAT下的数据源(修改contex.xml文件)<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version='1.0'&nbsp;encoding='utf-8'</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;The&nbsp;contents&nbsp;of&nbsp;this&nbsp;file&nbsp;will&nbsp;be&nbsp;loaded&nbsp;for&nbsp;each&nbsp;web&nbsp;application&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Resource&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="jdbc/app"</span><span style="color: rgb(255, 0, 0);">&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth</span><span style="color: rgb(0, 0, 255);">="Container"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</span><span style="color: rgb(0, 0, 255);">="javax.sql.DataSource"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;driverClassName</span><span style="color: rgb(0, 0, 255);">="com.mysql.jdbc.Driver"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url</span><span style="color: rgb(0, 0, 255);">="jdbc:mysql://localhost/app"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username</span><span style="color: rgb(0, 0, 255);">="user"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password</span><span style="color: rgb(0, 0, 255);">="pwd"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removeAbandoned</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removeAbandonedTimeout</span><span style="color: rgb(0, 0, 255);">="60"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logAbandoned</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxActive</span><span style="color: rgb(0, 0, 255);">="700"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxIdle</span><span style="color: rgb(0, 0, 255);">="30"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxWait</span><span style="color: rgb(0, 0, 255);">="10000"</span><span style="color: rgb(255, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;Default&nbsp;set&nbsp;of&nbsp;monitored&nbsp;resources&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">WatchedResource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WEB-INF/web.xml</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">WatchedResource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
因JBOSS和TOMCAT获取数据源连接的方式不同,又修改了获取连接的代码,启动之后是可以运行,页面读取数据正常,但写入数据库时,出现了乱码,我尝试着修改写入数据库的SQL语句的编码,但不管怎么修改都不能正常显示,后来试着通过URL直接修改连接的编码试试,于是把TOMCAT数据源配置里的URL指定为UTF-8的字符集<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);"> url="jdbc:mysql://localhost/app?useUnicode=true</span><span style="color: rgb(255, 0, 0);">&amp;amp;</span><span style="color: rgb(0, 0, 0);">characterEncoding=utf-8"<br />
</span></div>
这里再重新启动TOMCAT,运行后,数据写入正常,这个困扰我多天的问题终于解决了,之前没有想到这样的问题,以为JBOSS里也是用的TOMCAT,在JBOSS里配置的数据源都没有在URL里指定编码,没想到单独使用TOMCAT时会出现这样的问题,把今天的处理在这里作个记录,以便以后备查<br />
<br />
小结:<br />
当用MYSQL作数据库时,将应用程序从JBOSS迁移到TOMCAT,如果存在乱码的问题,可以考虑修改URL指定字符集<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/278085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-05-26 21:10 <a href="http://www.blogjava.net/zhouf/articles/278085.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>为JBOSS的远程控制台加锁</title><link>http://www.blogjava.net/zhouf/articles/264884.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Fri, 10 Apr 2009 09:01:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/264884.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/264884.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/264884.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/264884.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/264884.html</trackback:ping><description><![CDATA[下午看到一篇文章,说是JBOSS服务器可以通过远程的方式关闭服务,因为默认情况控制台的用户密码都为空,见前一篇文章,看到这个消息后,吃了一惊,因为我们有个东东正在用JBOSS做服务器,测试了一下,确实存在这样的问题,赶紧照着材料补了一下<br />
我用的JBOSS版本是Version: 4.0.4CR2,操作如下<br />
一、为jms-console加上认证<br />
修改jboss4\server\default\deploy\jmx-console.war\WEB-INF下的web.xml和jboss-web.xml<br />
在web.xml中把&lt;security-constraint&gt;的注释去掉<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp; </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">security-constraint</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">web-resource-collection</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">web-resource-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">HtmlAdaptor</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">web-resource-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">An&nbsp;example&nbsp;security&nbsp;config&nbsp;that&nbsp;only&nbsp;allows&nbsp;users&nbsp;with&nbsp;the<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role&nbsp;JBossAdmin&nbsp;to&nbsp;access&nbsp;the&nbsp;HTML&nbsp;JMX&nbsp;console&nbsp;web&nbsp;application<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/*</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">http-method</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">GET</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">http-method</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">http-method</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">POST</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">http-method</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">web-resource-collection</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">auth-constraint</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">role-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">JBossAdmin</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">role-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">auth-constraint</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">security-constraint</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
在jboss-web.xml中把&lt;security-domain&gt;注释去掉<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jboss-web</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;Uncomment&nbsp;the&nbsp;security-domain&nbsp;to&nbsp;enable&nbsp;security.&nbsp;You&nbsp;will<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;need&nbsp;to&nbsp;edit&nbsp;the&nbsp;htmladaptor&nbsp;login&nbsp;configuration&nbsp;to&nbsp;setup&nbsp;the<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;login&nbsp;modules&nbsp;used&nbsp;to&nbsp;authentication&nbsp;users.<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">security-domain</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">java:/jaas/jmx-console</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">security-domain</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jboss-web</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
然后修改jboss4\server\default\conf\props下的两个配置文件jmx-console-roles.properties和jmx-console-users.properties,添加用户和密码,搞定上面的配置之后,访问jms-console就需要认证了,下面继续web-console的配置<br />
二、为web-console加上认证<br />
在deploy目录下面没有看到web-console,就通过查找,结果找到了两个地方,分别是<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">jboss4\server\default\deploy\management\console-mgr.sar\web-console.war\<br />
jboss4\server\all\deploy\management\console-mgr.sar\web-console.war\</span></div>
我也没搞清楚倒底是哪个起作用,我改了其中一个试试,没效果,干脆两个都改了,改的步骤都是相同的,下面就对其中一个的配置进行说明了<br />
找到 WEB-INF\下面的jboss-web.xml和web.xml,修改的方法同上,去掉两个注释<br />
认证的文件放在了 WEB-INF\classes\下面,分别是web-console-roles.properties和web-console-users.properties,把用户的认证信息添加到里面即可,重新启动JBOSS,此时登录控制台会要求输入密码,我测试后发现有效的密码是default下面的配置,也搞不懂为什么要两个都改了才会弹出要求身份认证的对话框<br />
先暂时就记在这里吧,如果哪位有做深入的研究,希望可以多提意见完善这个文档<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/264884.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-04-10 17:01 <a href="http://www.blogjava.net/zhouf/articles/264884.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>补上JBOSS的远程控制台</title><link>http://www.blogjava.net/zhouf/articles/264875.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Fri, 10 Apr 2009 08:30:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/264875.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/264875.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/264875.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/264875.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/264875.html</trackback:ping><description><![CDATA[下午上班时，发现服务器竟然无法访问，没有停电呀。输入密码，解开x-window的锁定状态，发现jboss确实关闭了，时间是13:23分，发现时间是15:33分。<br />
这是以前没有从未出现过的，查服务器访问日志，原来是有人通过jmx-console远程关闭了服务器，我还从使用过这个功能，倒让人先用了！<br />
我知道，jboss安装默认情况下，jmx-console/web-console不用密码，就可以访问的，但我一直还以为，只能通过
localhost使用这个功能呢，所以就没有想道会有安全问题。我想，Jboss这么专业，这么成熟，这种小问题，自然不用操心，但我错了！<br />
重新启动服务器后，我自己模拟了一下，果然，不到一分钟时间，就找到了jmx-
console/HtmlAdaptor?action=inspectMBean&amp;
name=jboss.system:type=Server这个页面，其中有一个"shutdown",选择右边的invoke，果然服务器就关闭了。<br />
根据日志分析，一个ip地址为218.79.105.121的朋友，在6月20访问过本站，今天上午10点多，通过baidu读了一篇我的关于Jboss的文章，之后访问试验本站完全开放的jmx-console，试验了3个小时，终于找到了远程关闭服务器的方法。<br />
于是，他在上海徐汇的家中（Adsl，应该是家中吧），远程地关闭了我在架北京郊区自己办公室的服务器。<br />
这么大的漏洞被忽视了，真是汗颜。赶紧补课吧。<br />
<a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=SecureTheJmxConsole" target="_blank">SecureTheJmxConsole</a>,这可是Jboss官方文档.上面提示的做法，应当可行。但没有必要那么麻烦。<br />
只要进入jmx-console.war/web-console.war这2个包的WEB-INF,编辑jboss-web.xml,
web.xml就可以了。我只是在uncomment相应的部分之后，将jaas
domain替换我用的zhuoda.org，并且将security
role替换为我用的zduAdmin就都搞定了，不需要理会user.properties, roles-properties二个文件。<br />
<br />
转:http://www.zhuoda.org/hofman/21129.html<hr size="2" width="100%" />
以下的内容来自<a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=SecureTheJmxConsole" target="_blank">SecureTheJmxConsole</a>的链接<br />
<br />
<h2> Securing the JMX Console and Web Console</h2>
<p>Both the <a href="http://www.jboss.org/community/docs/DOC-10941">jmx-console</a> and <a href="http://www.jboss.org/community/docs/DOC-12659">web-console</a> are standard servlet 2.3 deployments and can</p>
<p>be secured using J2EE role based security. Both also have a skeleton setup to allow</p>
<p>one to easily enable security using username/password/role mappings found in the</p>
<p>jmx-console.war and web-console.war deployments in the corresponding WEB-INF/classes</p>
<p>users.properties and roles.properties files.</p>
<p>The security setup is based on two pieces, the standard <span style="font-family: courier new;">WEB-INF/web.xml</span> servlet URI</p>
<p>to role specification, and the <span style="font-family: courier new;">WEB-INF/jboss-web.xml</span> specification of the JAAS configuration which defines how authentication and role mapping is performed.</p>
<p>To secure the JMX Console using a username/password file -</p>
<ul>
    <li level="1" type="ul">
    <p>Locate the <span style="font-family: courier new;">jmx-console.war</span> directory.&nbsp; This will normally be in <span style="font-family: courier new;">server/default/deploy</span> in your <span style="font-family: courier new;">JBOSS_HOME</span> directory.</p>
    </li>
    <li level="1" type="ul">
    <p>edit <span style="font-family: courier new;">WEB-INF/web.xml</span> and uncomment the security-constraint block</p>
    </li>
    <li level="1" type="ul">
    <p>edit <span style="font-family: courier new;">WEB-INF/classes/jmx-console-users.properties</span> or <span style="font-family: courier new;">server/default/conf/props/jmx-console-users.properties</span> (version &gt;=4.0.2) and <span style="font-family: courier new;">WEB-INF/classes/jmx-console-roles.properties</span> or <span style="font-family: courier new;">server/default/conf/props/jmx-console-roles.properties</span>
    (version &gt;=4.0.2) and change the users and passwords to what you
    desire.&nbsp; They will need the JBossAdmin role specified in the web.xml
    file to run the JMX Console.</p>
    </li>
    <li level="1" type="ul">
    <p>edit <span style="font-family: courier new;">WEB-INF/jboss-web.xml</span>
    and uncomment the security-domain block. The security-domain value of
    jmx-console maps is declared in the login-config.xml JAAS configuration
    file which defines how authentication and authorization is done.</p>
    </li>
</ul>
<p>To secure the JMX Console using your own JAAS domain -</p>
<ul>
    <li level="1" type="ul">
    <p>edit <span style="font-family: courier new;">WEB-INF/web.xml</span>
    as above, uncommenting the security-constraint block.&nbsp; Change the
    role-name value to be the role in your domain that can access the
    console</p>
    </li>
    <li level="1" type="ul">
    <p>edit <span style="font-family: courier new;">WEB-INF/jboss-web.xml</span> as above, setting the security domain to be the name of your security domain.&nbsp; For example, if your <span style="font-family: courier new;">login-config.xml</span> has an application-policy whose name is <em>MyDomain</em> then your JAAS domain <span style="font-family: courier new;">java:/jaas/MyDomain</span></p>
    </li>
    <li level="1" type="ul">
    <p>after making all the changes, redeploy the application.&nbsp; The application can be redeployed by touching the <span style="font-family: courier new;">web.xml</span> file or by restarting the server</p>
    </li>
</ul>
<p>The process to secure the web console is similar.&nbsp; In the deploy directory, locate <span style="font-family: courier new;">management/web-console.war</span> and make the same changes as above to to <span style="font-family: courier new;">WEB-INF/web.xml</span>, </p>
<p><span style="font-family: courier new;">WEB-INF/jboss-web.xml</span> and the users/groups properties file.&nbsp; The default JAAS domain used by the web-console is <span style="font-family: courier new;">java:/jaas/web-console</span> and is defined in <span style="font-family: courier new;">login-config.xml</span>
in the conf directory.&nbsp; You can use a custom JAAS domain or custimize
the existing domain in the same way as with the JMX console. Typically
you would just use the same domain (java:/jaas/jmx-console) as the
jmx-console so that you have a single user/role mapping to configurue.</p>
<p><span>If
you find as I did with 3.2.5 that I couldn't log in, another
users.properties is most likely being picked up. Change the web-console
login-config.xml entry so that that properties files are uniquely named
to avoid ambiguity with which resource is picked up. You also would
need to rename the web-console properties files. (see </span><a href="http://www.jboss.org/index.html?module=bb&amp;op=viewtopic&amp;t=53346">http://www.jboss.org/index.html?module=bb&amp;op=viewtopic&amp;t=53346</a> )</p>
<p>As an extra level of security you may also want to LimitAccessToCertainClients in a particular IP address range.</p>
<p>-</p>
<hr originaltext="----" />
<p><strong>Update for 4.0.2</strong></p>
<p>The <span style="font-family: courier new;">jmx-console-roles.properties</span> and <span style="font-family: courier new;">jmx-console-users.properties</span> files have been moved to <span style="font-family: courier new;">server"default"conf"props</span>.
This is because of the change to use the servlet 2.3 class loading
model and these properties files would not be visible to the other
deployments using the jmx-console security domain. You can&nbsp; move the
files from <span style="font-family: courier new;">conf"props</span> to <span style="font-family: courier new;">WEB-INF"classes</span>, or leave them in place and edit the password for admin.</p>
<p>Similarly for the web console, please note that the web console is unpacked already in the default server configuration as <span style="font-family: courier new;">deploy/management/console-mgr.sar/web-console.war</span>. Proceed to edit the <span style="font-family: courier new;">WEB-INF/web.xml</span> and <span style="font-family: courier new;">jboss-web.xml</span> files as per securing the JMX console, and either edit the <span style="font-family: courier new;">WEB-INF/classes/web-console-roles.properties</span> and <span style="font-family: courier new;">web-console-users.properties</span>, or move those files to <span style="font-family: courier new;">server"default"conf"props</span> and edit them there.</p>
<p><strong>For the impatient</strong></p>
<p>vi $JBOSS_HOME/server/default/deploy/jmx-console.war/WEB-INF/web.xml</p>
<p>uncomment the security-constraint block</p>
<p>and add a &lt;login-config&gt; block after the end of the &lt;security-constraint&gt; block:</p>
<p><span style="font-family: courier new;">&nbsp;&nbsp;
&lt;login-config&gt;
&lt;auth-method&gt;BASIC&lt;/auth-method&gt;
&lt;realm-name&gt;JMXConsole&lt;/realm-name&gt;
&lt;/login-config&gt;
</span></p>
<p>vi $JBOSS_HOME/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml</p>
<p>Uncomment the security-domain block. Make sure the JNDI name maps to the realm name (i.e. JMXConsole)</p>
<p>vi $JBOSS_HOME/server/default/conf/props/jmx-console-users.properties</p>
<p>change the password for admin</p>
<p>vi $JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/web.xml</p>
<p>uncomment the security-constraint block</p>
<p>and add a &lt;login-config&gt; block after the end of the &lt;security-constraint&gt; block:</p>
<p><span style="font-family: courier new;">&nbsp;&nbsp;
&lt;login-config&gt;
&lt;auth-method&gt;BASIC&lt;/auth-method&gt;
&lt;realm-name&gt;JMXConsole&lt;/realm-name&gt;
&lt;/login-config&gt;
</span></p>
<p>vi $JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/jboss-web.xml</p>
<p>Uncomment the security-domain block. Make sure the JNDI name maps to the realm name (e.g. JMXConsole)</p>
<p>vi $JBOSS_HOME/server/default/conf/login-config.xml</p>
<p>Change
the path to the web-console-users.properties and the
web-console-roles.properties as follows (add props/ to the front of the
path)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;module-option name="usersProperties"&gt;props/web-console-users.properties&lt;/module-option&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;module-option name="rolesProperties"&gt;props/web-console-roles.properties&lt;/module-option&gt;</p>
<p>cp
$JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/classes/web-console-.properties
$JBOSS_HOME/server/default/conf/props</p>
<p>edit as needed</p>
<p>cp
$JBOSS_HOME/server/default/conf/props/jmx-console-roles.properties
$JBOSS_HOME/server/default/conf/props/web-console-roles.properties</p>
<p>edit as needed</p>
<p>edit
$JBOSS_HOME/server/default/conf/login-config.xml, find the jmx-console
and web-console applicaiton-policy, and set the name to jmx-console and
web-console, respectively. That is make sure that the application
policy name maps to the realm name (i.e. JMXConsole)</p>
<p>restart jboss</p>
<hr originaltext="----" />
<p><strong>Additional to secure jmx-console and web-console authentication via SSL</strong></p>
<ul>
    <li level="1" type="ul">
    <p>must perform the above steps to enable http authenication ...</p>
    </li>
</ul>
<p>&nbsp;&nbsp; the following steps below will redirect jboss admin pages to <a href="https://localhost:8443/">https://localhost:8443</a></p>
<ul>
    <li level="1" type="ul">
    <p>edit both web.xml to include the following just before end of tag security-constraint </p>
    </li>
</ul>
<p><span style="font-family: courier new;">&nbsp;&nbsp;
&lt;security-constraint&gt;
&nbsp; ...
&nbsp; &lt;user-data-constraint&gt;
&nbsp;&nbsp;&nbsp; &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
&nbsp; &lt;/user-data-constraint&gt;
&lt;/security-constraint&gt;
</span></p>
<ul>
    <li level="1" type="ul">
    <p>generate /data01/jboss/server/xxxx/conf/keystore and select your own new secure password</p>
    </li>
</ul>
<p>(@see creating SSL keystore using the java keytool - <a href="http://www.informit.com/articles/article.asp?p=407886">http://www.informit.com/articles/article.asp?p=407886</a>)</p>
<p>or quick setup and verify via </p>
<p><span style="font-family: courier new;">
$ keytool -genkey -keystore /data01/jboss/server/xxx/conf/keystore -alias jbossAdmin
$ keytool -list -keystore /data01/jboss/server/xxx/conf/keystore
</span></p>
<p>$vi /data01/jboss/server/xxx/deploy/jbossweb-tomcat50.sar/server.xml</p>
<ul>
    <li level="1" type="ul">
    <p>secure file permission via chmod 600 server.xml</p>
    </li>
    <li level="1" type="ul">
    <p>uncomment section "SSL/TLS Connector" to enable Connector port="8443"</p>
    </li>
    <li level="1" type="ul">
    <p>replace keystoreFile="${jboss.server.home.dir}/conf/chap8.keystore" </p>
    </li>
</ul>
<p>&nbsp; with&nbsp;&nbsp;&nbsp; keystoreFile="${jboss.server.home.dir}/conf/keystore"</p>
<ul>
    <li level="1" type="ul">
    <p>replace keystorePass="rmi+ssl" sslProtocol = "TLS" /&gt; </p>
    </li>
</ul>
<p>&nbsp; with&nbsp;&nbsp;&nbsp; keystorePass="</p>
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/264875.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-04-10 16:30 <a href="http://www.blogjava.net/zhouf/articles/264875.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在TOMCAT下自定义404错误页面</title><link>http://www.blogjava.net/zhouf/articles/264639.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Thu, 09 Apr 2009 06:46:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/264639.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/264639.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/264639.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/264639.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/264639.html</trackback:ping><description><![CDATA[在Tomcat安装目录下的conf/web.xml最后的&lt;/web-app&gt;之前增加如下代码<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">error-page</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">error-code</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">404</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">error-code</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/web404.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">error-page</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
也可以在应用的WEB-INF/web.xml下加入上述代码<br />
然后建立web404.jsp自定义的页面,在页面里显示提示信息3秒后转到起始页面,我写的页面代码如下<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&lt;%</span><span style="color: rgb(0, 0, 0);">@&nbsp;page&nbsp;language</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;contentType</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/html;&nbsp;charset=UTF-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;pageEncoding</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">UTF-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;!</span><span style="color: rgb(0, 0, 0);">DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">-//W3C//DTD&nbsp;HTML&nbsp;4.01&nbsp;Transitional//EN</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.w3.org/TR/html4/loose.dtd</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;%</span><span style="color: rgb(0, 0, 0);"><br />
String&nbsp;path&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;request.getContextPath();<br />
String&nbsp;basePath&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;request.getScheme()</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">://</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">request.getServerName()</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">request.getServerPort()</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">path</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />
</span><span style="color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">meta&nbsp;http</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">equiv</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Content-Type</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;content</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/html;&nbsp;charset=UTF-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">meta&nbsp;http</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">equiv</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">refresh</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;content</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">3;url=&lt;%=basePath%&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">资源错误</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">title</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">head</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">body</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">div&nbsp;align</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">center</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;&lt;</span><span style="color: rgb(0, 0, 0);">h1</span><span style="color: rgb(0, 0, 0);">&gt;&lt;</span><span style="color: rgb(0, 0, 0);">font&nbsp;color</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">#800000</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">对不起,你所访问的页面不存在</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">font</span><span style="color: rgb(0, 0, 0);">&gt;&lt;/</span><span style="color: rgb(0, 0, 0);">h1</span><span style="color: rgb(0, 0, 0);">&gt;&lt;/</span><span style="color: rgb(0, 0, 0);">div</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">body</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">html</span><span style="color: rgb(0, 0, 0);">&gt;</span></div>
经测试,访问一个不存在的页面,则转到自定义的页面,3秒后转到起始页,只要自定义页面能够被访问,那么是否进行跳转或是要进行其它什么操作就由你自己决定了<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/264639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-04-09 14:46 <a href="http://www.blogjava.net/zhouf/articles/264639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>eWebEditor在JBOSS下无法显示的问题</title><link>http://www.blogjava.net/zhouf/articles/264392.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Wed, 08 Apr 2009 01:40:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/264392.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/264392.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/264392.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/264392.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/264392.html</trackback:ping><description><![CDATA[在将一个Tomcat项目迁移到JBOSS时,出现了一点问题,就是配置好的eWebEditor不能用了,控制台里报以下的错误<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">Exception&nbsp;in&nbsp;JSP:&nbsp;</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">eWebEditor.jsp:</span><span style="color: rgb(0, 0, 0);">54</span></div>
经过一番折腾后又发现了如下的出错提示<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">java.lang.NoClassDefFoundError:&nbsp;org</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">dom4j</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">xpath</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">DefaultXPath</span></div>
后来发现是dom4j.jar版本不对造成的问题,JBOSS自带的版本会出现上述的情况<br />
解决方法如下:<br />
将eWebEditor里自带的dom4j.jar(476K)的文件覆盖掉jboss4\lib\dom4j.jar(297K)即可,本文参考以下的材料<br />
<hr size="2" width="100%" />
The error "java.lang.NoClassDefFoundError: org/dom4j/xpath/DefaultXPath" underlines important changes to the dom4j XML library. It usually happens when you try to call this library's methods in runtime. Older versions that shipped with JBoss used to include Jaxen, but for whatever reason, it is no longer included. Users must download dom4j.jar (now at version 1.6.1) and then jaxen-full.jar (FCS-1.0). Now how to resolve this problem is tricky:<br />
<br />
&nbsp;&nbsp; 1. Put dom4j-1.3.jar in {jboss}/lib. This version is known good.<br />
&nbsp;&nbsp; 2. Put dom4j-1.6.1.jar and jaxen-full.jar in {jboss}/server/default/lib. Remove the old dom4j JARs that may exist in that directory.<br />
<br />
The reason the newer version cannot be used with JBoss is unknown, but it does not work. The older version is used when reading JBoss-specific config files. The newer version of dom4j kicks in when the default server is initialized. This allows development of applications using newer versions of the XML API.<br />
<br />
http://prideafrica.blogspot.com/2006/05/javalangnoclassdeffounderror.html<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/264392.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-04-08 09:40 <a href="http://www.blogjava.net/zhouf/articles/264392.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat6 数据连接池配置</title><link>http://www.blogjava.net/zhouf/articles/258225.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Fri, 06 Mar 2009 07:47:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/258225.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/258225.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/258225.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/258225.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/258225.html</trackback:ping><description><![CDATA[Tomcat6 和 Tomcat5的配置不一样,我按Tomcat5的配置方法,就是报错,以前是把配置写在server.xml里,但在Tomcat6里面是把配置写在conf/context.xml里<br />
把数据库驱动放到lib目录下<br />
配置tomcat下的conf下的context.xml文件,在&lt;context&gt;&lt;/context&gt;之间添加连接池如下<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Resource&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="jdbc/mysql"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;auth</span><span style="color: rgb(0, 0, 255);">="Container"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;type</span><span style="color: rgb(0, 0, 255);">="javax.sql.DataSource"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;driverClassName</span><span style="color: rgb(0, 0, 255);">="com.mysql.jdbc.Driver"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;url</span><span style="color: rgb(0, 0, 255);">="jdbc:mysql://localhost/test"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;username</span><span style="color: rgb(0, 0, 255);">="root"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;password</span><span style="color: rgb(0, 0, 255);">="root"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;maxActive</span><span style="color: rgb(0, 0, 255);">="100"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;maxIdle</span><span style="color: rgb(0, 0, 255);">="30"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;maxWait</span><span style="color: rgb(0, 0, 255);">="10000"</span><span style="color: rgb(255, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">/&gt;</span></div>
配置你的应用下的web.xml中的&lt;web-app&gt;&lt;/web-app&gt;之间加入<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">DB&nbsp;Connection</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc/mysql</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">javax.sql.DataSource</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Container</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp; <br />
</span></div>
配置好了之后就可以通过下面的方式获取数据库连接<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">DataSource&nbsp;ds&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;&nbsp;&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);">{&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;InitialContext&nbsp;ctx</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;InitialContext();&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;ds</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">(DataSource)ctx.lookup(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java:comp/env/jdbc/mysql</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Connection&nbsp;conn&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;ds.getConnection();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.blogjava.net/Images/dot.gif" alt="" /><img src="http://www.blogjava.net/Images/dot.gif" alt="" /><br />
}</span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);">(Exception&nbsp;ex){&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace();&nbsp;&nbsp;&nbsp;<br />
} <br />
</span></div>
<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/258225.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-03-06 15:47 <a href="http://www.blogjava.net/zhouf/articles/258225.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat 连接池泄露的问题</title><link>http://www.blogjava.net/zhouf/articles/253901.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Mon, 09 Feb 2009 06:04:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/253901.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/253901.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/253901.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/253901.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/253901.html</trackback:ping><description><![CDATA[1 问题描述<br />
Web程序在tomcat刚开始运行时速度很快，但过一段时间后发现速度变得很慢。<br />
检查日志输出，发现异常如下:<br />
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause:<br />
java.util.NoSuchElementException: Timeout waiting for idle object<br />
同时在SQLServer事件探查器中发现，每执行一次sql语句都要产生Audit login事件，语句执行后产生<br />
Audit logout事件。说明每一次tomcat都是重新打开新的连接。<br />
2 问题解决<br />
tomcat 的数据源定义提供了三个参数：<br />
a. 如果设为true则tomcat自动检查恢复重新利用，没有正常关闭的Connection.（默认是false）<br />
&lt;parameter&gt;<br />
&lt;name&gt;removeAbandoned&lt;/name&gt;<br />
&lt;value&gt;true&lt;/value&gt;<br />
&lt;/parameter&gt;<br />
b. 设定连接在多少秒内被认为是放弃的连接，即可进行恢复利用。<br />
&lt;parameter&gt;<br />
&lt;name&gt;removeAbandonedTimeout&lt;/name&gt;<br />
&lt;value&gt;60&lt;/value&gt;<br />
&lt;/parameter&gt;<br />
c. 输出回收的日志，可以详细打印出异常从而发现是在那里发生了泄漏<br />
&lt;parameter&gt;<br />
&lt;name&gt;logAbandoned&lt;/name&gt;<br />
&lt;value&gt;true&lt;/value&gt;<br />
&lt;/parameter&gt;
<img src ="http://www.blogjava.net/zhouf/aggbug/253901.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-02-09 14:04 <a href="http://www.blogjava.net/zhouf/articles/253901.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将应用程序部署到Tomcat的根</title><link>http://www.blogjava.net/zhouf/articles/251646.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Fri, 16 Jan 2009 16:05:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/251646.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/251646.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/251646.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/251646.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/251646.html</trackback:ping><description><![CDATA[在Tomcat下部署应用的时候,访问时会在地址栏加上应用名如:htt://host:8000/prj<br />
有时我们希望通过如下方式访问http://host<br />
为此,有两个地方需要进行修改,一是修改Tomcat服务端口,二是修改应用的访问路径<br />
修改服务端口只需改到Tomcat\conf\server.xml<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;Define&nbsp;a&nbsp;non-SSL&nbsp;Coyote&nbsp;HTTP/1.1&nbsp;Connector&nbsp;on&nbsp;the&nbsp;port&nbsp;specified&nbsp;during&nbsp;installation&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Connector&nbsp;</span><span style="color: rgb(255, 0, 0);">port</span><span style="color: rgb(0, 0, 255);">="80"</span><span style="color: rgb(255, 0, 0);">&nbsp;maxThreads</span><span style="color: rgb(0, 0, 255);">="150"</span><span style="color: rgb(255, 0, 0);">&nbsp;minSpareThreads</span><span style="color: rgb(0, 0, 255);">="25"</span><span style="color: rgb(255, 0, 0);">&nbsp;maxSpareThreads</span><span style="color: rgb(0, 0, 255);">="75"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enableLookups</span><span style="color: rgb(0, 0, 255);">="false"</span><span style="color: rgb(255, 0, 0);">&nbsp;redirectPort</span><span style="color: rgb(0, 0, 255);">="8443"</span><span style="color: rgb(255, 0, 0);">&nbsp;acceptCount</span><span style="color: rgb(0, 0, 255);">="100"</span><span style="color: rgb(255, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(255, 0, 0);">&nbsp;connectionTimeout</span><span style="color: rgb(0, 0, 255);">="20000"</span><span style="color: rgb(255, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disableUploadTimeout</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">/&gt;</span></div>
将port的值改为80即可,前提是80端口没有被使用,如果已被占用,启动Tomcat时会出现端口被占用的提示信息<br />
<br />
下一步是修改应用程序访问路径<br />
方法一:<br />
在Tomcat\conf\Catalina\localhost\目录下找到对应工程的xml文件,如此处为Tomcat\conf\Catalina\localhost\prj.xml<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version='1.0'&nbsp;encoding='utf-8'</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context&nbsp;</span><span style="color: rgb(255, 0, 0);">displayName</span><span style="color: rgb(0, 0, 255);">="prj Name"</span><span style="color: rgb(255, 0, 0);">&nbsp;docBase</span><span style="color: rgb(0, 0, 255);">="prj"</span><span style="color: rgb(255, 0, 0);">&nbsp;path</span><span style="color: rgb(0, 0, 255);">=""</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
将其path的值改为空,另外还要将Tomcat\conf\Catalina\localhost\ROOT.xml 的path值改为另一个值,要不启动Tomcat时会有冲突,如改成以下的状态<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version='1.0'&nbsp;encoding='utf-8'</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context&nbsp;</span><span style="color: rgb(255, 0, 0);">displayName</span><span style="color: rgb(0, 0, 255);">="Welcome&nbsp;to&nbsp;Tomcat"</span><span style="color: rgb(255, 0, 0);">&nbsp;docBase</span><span style="color: rgb(0, 0, 255);">="ROOT"</span><span style="color: rgb(255, 0, 0);">&nbsp;path</span><span style="color: rgb(0, 0, 255);">="/ROOT"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span></div>
在完成上述改动后,就可以通过主机地址的方式访问应用程序了,如http://host<br />
<br />
方法二:<br />
如果按上面的方法配置不成功,还可以试试修改server.xml,在&lt;Host&gt;...&lt;/Host&gt;里加上如下信息<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context&nbsp;</span><span style="color: rgb(255, 0, 0);">displayName</span><span style="color: rgb(0, 0, 255);">="prj&nbsp;Name"</span><span style="color: rgb(255, 0, 0);">&nbsp;docBase</span><span style="color: rgb(0, 0, 255);">="prj"</span><span style="color: rgb(255, 0, 0);">&nbsp;path</span><span style="color: rgb(0, 0, 255);">=""</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
这样就不用管Tomcat\conf\Catalina\localhos目录了<br />
刚做完上面的测试,把过程做一个记录写在这里,以便以后查阅<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/251646.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-01-17 00:05 <a href="http://www.blogjava.net/zhouf/articles/251646.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UrlRewrite的使用记录</title><link>http://www.blogjava.net/zhouf/articles/251531.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Fri, 16 Jan 2009 01:50:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/251531.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/251531.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/251531.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/251531.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/251531.html</trackback:ping><description><![CDATA[为了不在地址栏里暴露过多的信息,想到了做一个地址的隐藏,在网上找了一些资料,决定试试UrlRewriet<br />
在网上下载了<a href="http://tuckey.org/urlrewrite/">urlrewrite</a>的包,我下载的是urlrewritefilter-2.6-src.zip<br />
打开压缩包,将里面的urlrewrite-2.6.0.jar放在工程的/WEB-INF/lib/目录下<br />
将里面的urlrewrite.xml放在工程的/WEB-INF/目录下<br />
修改/WEB-INF/web.xml,加入过滤器<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">UrlRewriteFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">init-param</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">param-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">logLevel</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">param-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">param-value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WARN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">param-value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">init-param</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">UrlRewriteFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/*</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
在urlrewrite.xml里加入规则,如:<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;rule&nbsp;means&nbsp;that&nbsp;requests&nbsp;to&nbsp;/page/pagea.html&nbsp;will&nbsp;be&nbsp;redirected&nbsp;to&nbsp;/pagea.jsp<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/html/([a-z]+).html</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/$1.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
此时在浏览器里访问/html/pagea.html会显示/pagea.jsp的内容,OK,搞定<br />
如果这种地址隐藏可行,那么可以把jsp页面伪装成asp或是php页面,改写规则如下<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;rule&nbsp;means&nbsp;that&nbsp;requests&nbsp;to&nbsp;/html/pagea.html&nbsp;will&nbsp;be&nbsp;redirected&nbsp;to&nbsp;/pagea.jsp<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/html/([a-z]+).html</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/$1.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;rule&nbsp;means&nbsp;that&nbsp;requests&nbsp;to&nbsp;/asp/pagea.asp&nbsp;will&nbsp;be&nbsp;redirected&nbsp;to&nbsp;/pagea.jsp<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/asp/([a-z]+).asp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/$1.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;rule&nbsp;means&nbsp;that&nbsp;requests&nbsp;to&nbsp;/php/pagea.php&nbsp;will&nbsp;be&nbsp;redirected&nbsp;to&nbsp;/pagea.jsp<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">note</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/php/([a-z]+).php</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">from</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/$1.jsp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">to</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">rule</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span></div>
此时,在浏览器里输入<br />
/html/pagea.html<br />
/asp/pagea.asp<br />
/php/pagea.php<br />
均可以访问页面pagea.jsp<br />
几个月前我写了一篇笔记做地址伪装的,看来完全可以用这个东东代替了,上次写的那个还有一些问题没有完全解决,用urlrewrite做地址隐藏,真是感觉很专业,完美呀,初次使用,可能有些高级的功能还没有用到,不过通过这样的试验,已感觉出它的强大,这应该是一个很好的解决方案.<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/251531.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-01-16 09:50 <a href="http://www.blogjava.net/zhouf/articles/251531.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat 数据源</title><link>http://www.blogjava.net/zhouf/articles/251413.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Thu, 15 Jan 2009 04:28:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/251413.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/251413.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/251413.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/251413.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/251413.html</trackback:ping><description><![CDATA[前面写了一段在Tomcat中配置数据连接池的操作,那是在网上找的一篇,在此把我的操作过程记录一下<br />
将jdbc数据库驱动包放到%Tomcat_Home%\common\lib下面<br />
打开%Tomcat_Home%\conf\server.xml,在&lt;/host&gt;前添加如下信息<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context&nbsp;</span><span style="color: rgb(255, 0, 0);">path</span><span style="color: rgb(0, 0, 255);">="/lib"</span><span style="color: rgb(255, 0, 0);">&nbsp;docBase</span><span style="color: rgb(0, 0, 255);">="lib"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Resource&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="jdbc/lib"</span><span style="color: rgb(255, 0, 0);">&nbsp;scope</span><span style="color: rgb(0, 0, 255);">="Shareable"</span><span style="color: rgb(255, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 255);">="javax.sql.DataSource"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ResourceParams&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="jdbc/lib"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">factory</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">org.apache.commons.dbcp.BasicDataSourceFactory</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;DBCP&nbsp;database&nbsp;connection&nbsp;settings&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">url</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc:mysql://localhost/lib</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">driverClassName</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">com.mysql.jdbc.Driver</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">username</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">root</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">&nbsp;DBCP&nbsp;connection&nbsp;pooling&nbsp;options&nbsp;</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">maxWait</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">3000</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">maxIdle</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">100</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">maxActive</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">10</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">parameter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">ResourceParams</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />
</span></div>
在其应用工程的WEB.XML中添加数据源的引用<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc/lib</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">javax.sql.DataSource</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Container</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
然后写一个测试的页面<br />
需要三个包<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">java.sql.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />
javax.naming.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"><br />
javax.sql.DataSource</span></div>
通过下面的方式获取连接<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">InitialContext&nbsp;ctx</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;InitialContext();<br />
DataSource&nbsp;ds</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">(DataSource)ctx.lookup(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java:comp/env/jdbc/lib</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
Connection&nbsp;&nbsp;conn</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">ds.getConnection();</span></div>
测试通过,可以获取连接,配置完成!!!<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/251413.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-01-15 12:28 <a href="http://www.blogjava.net/zhouf/articles/251413.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat连接池配置</title><link>http://www.blogjava.net/zhouf/articles/251412.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Thu, 15 Jan 2009 04:17:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/251412.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/251412.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/251412.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/251412.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/251412.html</trackback:ping><description><![CDATA[有两种配置方法：<br />
第一种：仅为一个具体的工程所使用而配置的数据源<br />
第一步：打开%Tomcat_Home%\conf\server.xml,在&lt;/Context&gt;和&lt;/host&gt;前添加描述<br />
&lt;Context path="/lib" docBase ="lib" debug="0" reloadable ="true" crossContext="true"&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;Resource name = "jdbc/mydatasource" auth="Container" type="javax.sql.DataSource"/&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;ResourceParams name ="jdbc/libds"&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;factory&lt;/name&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;org.apache.commons.dbcp.BasicDataSourceFactory&lt;/value&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;driverClassName&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;url&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;jdbc:mysql://localhost/lib&lt;/value&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;username&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;root&lt;/value&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;password&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;password&lt;/value&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;maxActive&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;20&lt;/value&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;maxIdle&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;10&lt;/value&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;parameter&gt;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;maxWait&lt;/name&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;-1&lt;/value&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; &lt;/parameter&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/ResourceParams&gt;<br />
&lt;/Context&gt;<br />
注释： &#8220;ch13&#8221;是工程名，JNDI name 是 &#8220;jdbc/libds&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用户名和密码都是"sa"<br />
第二步，将ms sqlserver要用到的三个驱动包复制到%tomcat_home%\common\lib目录下。<br />
第三步，重新启动tomcat。<br />
第四步,可以在工程ch13里写个测试j页面test.jsp：<br />
&lt;%@pageimport="java.sql.*"%&gt;<br />
&lt;%@pageimport="javax.sql.*"%&gt;<br />
&lt;%@pageimport="javax.naming.*"%&gt;<br />
&lt;%<br />
&nbsp; DataSource ds=null;<br />
&nbsp; try{<br />
&nbsp; InitialContext ctx=new InitialContext();<br />
&nbsp; ds=(DataSource)ctx.lookup("java:comp/env/jdbc/libds");<br />
&nbsp; Connection&nbsp; conn=ds.getConnection();<br />
&nbsp; Statement stmt=conn.createStatement();<br />
&nbsp; String strSql="select *&nbsp; from&nbsp; authors";<br />
&nbsp; ResultSet rs=stmt.executeQuery(strSql);<br />
&nbsp; while(rs.next()){<br />
&nbsp;&nbsp;&nbsp;&nbsp; out.println(rs.getString(1)+"&lt;br&gt;");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp; }<br />
&nbsp; catch(Exception ex){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.println("出错啦!!!");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ex.printStackTrace();<br />
&nbsp; }<br />
%&gt;<br />
如果能正常显示多行数据则测试成功，否则失败。<br />
<br />
<br />
第二种是针对Tomcat中所有的工程进行的配置,可以使用Tomcat图形界面进行设置<br />
&nbsp;第一步,通过IE浏览器进入Tomcat Administration ,用户名和密码就是安装tomcat时设置的密码.,然后选择create&nbsp; New&nbsp; DataSource.<br />
输入如下:<br />
JNDI name :jdbc/allds<br />
Data Source URL:jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=pubs<br />
JDBC Driver Class:com.microsoft.jdbc.sqlserver.SQLServerDriver<br />
User Name:sa<br />
password :sa<br />
可根据实际修改密码<br />
第二步 :在%tomcat_home%/conf/Catalina\localhost目录下找到要使用此数据源的工程同名的xml文件.<br />
在Context一节中加入以下代码：<br />
&lt;ResourceLink name="jdbc/allds" global="jdbc/allds" type="javax.sql.DataSourcer"/&gt;<br />
第三步,在%tomcat_home%'/common/lib中添加要用到的sqlserver的驱动包,重新启动tomcat.<br />
第四步,测试.在刚才要使用数据源的工程中添加test.jsp,代码如下:<br />
&lt;%@pageimport="java.sql.*"%&gt;<br />
&lt;%@pageimport="javax.sql.*"%&gt;<br />
&lt;%@pageimport="javax.naming.*"%&gt;<br />
&lt;%<br />
&nbsp; DataSource ds=null;<br />
&nbsp; try{<br />
&nbsp; InitialContext ctx=new InitialContext();<br />
&nbsp; ds=(DataSource)ctx.lookup("java:comp/env/jdbc/allds");<br />
&nbsp; Connection&nbsp; conn=ds.getConnection();<br />
&nbsp; Statement stmt=conn.createStatement();<br />
&nbsp; String strSql="select *&nbsp; from&nbsp; authors";<br />
&nbsp; ResultSet rs=stmt.executeQuery(strSql);<br />
&nbsp; while(rs.next()){<br />
&nbsp;&nbsp;&nbsp;&nbsp; out.println(rs.getString(2)+"&lt;br&gt;");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp; }<br />
&nbsp; catch(Exception ex){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.println("出错啦!!!");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ex.printStackTrace();<br />
&nbsp; }<br />
%&gt;<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/251412.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-01-15 12:17 <a href="http://www.blogjava.net/zhouf/articles/251412.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBoss数据源加密</title><link>http://www.blogjava.net/zhouf/articles/250178.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Tue, 06 Jan 2009 13:24:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/250178.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/250178.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/250178.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/250178.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/250178.html</trackback:ping><description><![CDATA[<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">1.我们先来看一个普通的数据源配置文件&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">MySqlDS</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">use-java-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">use-java-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc:mysql://10.16.175.137:3306/test</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">com.mysql.jdbc.Driver</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">user-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">root</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">user-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">123</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">password</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;//注意这里的密码是明文显示的！！<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">exception-sorter-class-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">exception-sorter-class-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">mySQL</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;看一下这个文件,里面用户名与密码都是以明文方式存储的,这样子对系统的安全而言带来了极大的威协。所以我们要为我们这个明文的密码加一下密,这就是本文的目的。<br />
<br />
2.说到密码加密，这里我们用到了JBoss下的一个类org.jboss.resource.security.SedureIdentityLoginModule。<br />
看看我们该如何用它来帮我们的密码加密。&nbsp;<br />
<br />
a.先看个配置数据源的例子(mysql-ds.xml)：&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">MySqlDS</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">use-java-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">use-java-context</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jdbc:mysql://localhost:3306/test</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">connection-url</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">com.mysql.jdbc.Driver</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">driver-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">security-domain</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SuperPassword</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">security-domain</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">//这里不用写上你的用户名与密码了，我们可以在login-config.xml里做点手脚，就OK了！用这一行替换掉了上面那个文件的两行。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">exception-sorter-class-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">exception-sorter-class-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">MySQL</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">type-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">metadata</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">local-tx-datasource</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">datasources</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
<br />
<br />
接着我们修改server\default\conf\login-config.xml文件,加上下面这一段配置文件：<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">application-policy&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="SuperPassword"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;//这里的name应该是你在配置数据源时写的security-domain里的字符串&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">authentication</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">login-module&nbsp;</span><span style="color: rgb(255, 0, 0);">code</span><span style="color: rgb(0, 0, 255);">="org.jboss.resource.security.SecureIdentityLoginModule"</span><span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag</span><span style="color: rgb(0, 0, 255);">="required"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">module-option&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="username"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">root</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">module-option</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;//数据库的用户名&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">module-option&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="password"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">2f34371127b18a0b</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">module-option</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;//数据库的密码，不过是加密过的了&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">module-option&nbsp;</span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="managedConnectionFactoryName"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">jboss.jca:service=LocalTxCM,name=MySqlDS</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">module-option</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//注意name等于你的数据源的jndi-name,这里我的是MySqlDS&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">login-module</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">authentication</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">application-policy</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
<br />
3.上面的被加密过后的密码2f34371127b18a0b是哪里来的呢？照下面的方法就可以弄出来了。<br />
在命令行下运行：<br />
java&nbsp;-cp&nbsp;"D:\JBoss\lib\jboss-jmx.jar;D:\JBoss\lib\jboss-common.jar;D:\JBoss\server\default\lib\jboss-jca.jar;D:\JBoss\server\default\lib\jbosssx.jar"&nbsp;org.jboss.resource.security.SecureIdentityLoginModule&nbsp;123<br />
<br />
运行结果：Encoded&nbsp;password:&nbsp;2f34371127b18a0b<br />
<br />
就这样。把上面命令的路径和密码换换就OK了。<br />
<br />
</span></div>
<img src ="http://www.blogjava.net/zhouf/aggbug/250178.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2009-01-06 21:24 <a href="http://www.blogjava.net/zhouf/articles/250178.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在JBOSS中使用JSTL</title><link>http://www.blogjava.net/zhouf/articles/227827.html</link><dc:creator>ZhouFeng</dc:creator><author>ZhouFeng</author><pubDate>Mon, 08 Sep 2008 15:10:00 GMT</pubDate><guid>http://www.blogjava.net/zhouf/articles/227827.html</guid><wfw:comment>http://www.blogjava.net/zhouf/comments/227827.html</wfw:comment><comments>http://www.blogjava.net/zhouf/articles/227827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhouf/comments/commentRss/227827.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhouf/services/trackbacks/227827.html</trackback:ping><description><![CDATA[今天,经过一番折腾,终于在JBOSS中用上了JSTL,心里感觉蛮有点收获的,花点时间写下一点笔记<br />
首先在APACHE网站上可以下载JSTL(我下载的是<a href="http://www.apache.org/dist/jakarta/taglibs/standard/binaries/jakarta-taglibs-standard-1.1.2.zip">jakarta-taglibs-standard-1.1.2.zip</a>),可能后面的版本会有点变化<br />
解压ZIP文件,将里面的standard.jar和jstl.jar文件放在工程中的/WEB-INF/lib目录中<br />
在/WEB-INF目录下建一个新的文件夹tld<br />
将zip文件里的*.tld文件解压放在/WEB-INF/tld目录中<br />
修改/WEB-INF/web.xml文件加入如下内容<br />
<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/fmt</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/fmt.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/fmt-rt</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/fmt-1_0-rt.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/core</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/c.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/core-rt</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/c-1_0-rt.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/sql</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/sql.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/sql-rt</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/sql-1_0-rt.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/x</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/x.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">http://java.sun.com/jstl/x-rt</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-uri</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">/WEB-INF/tld/x-1_0-rt.tld</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib-location</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">taglib</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />
</span></div>
其实可以根据使用的情况,仅将需要的tld加入到工程<br />
布置好了.jar文件和.tld文件,以及修改了web.xml文件后,就可以在JSP页面里试试JSTL标签的魅力了<br />
stulist.jsp<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@&nbsp;page&nbsp;language</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">java</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;import</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">java.util.*</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;pageEncoding</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">UTF-8</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@&nbsp;taglib&nbsp;uri</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">http://java.sun.com/jsp/jstl/sql</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;prefix</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">sql</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&lt;%</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">@&nbsp;taglib&nbsp;uri</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">http://java.sun.com/jsp/jstl/core</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;prefix</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">c</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">"</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">&nbsp;</span><span style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">%&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 0, 255);">&lt;!</span><span style="color: rgb(255, 0, 255);">DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;HTML&nbsp;4.01&nbsp;Transitional//EN"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">page</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">sql:query&nbsp;</span><span style="color: rgb(255, 0, 0);">var</span><span style="color: rgb(0, 0, 255);">="rs"</span><span style="color: rgb(255, 0, 0);">&nbsp;dataSource</span><span style="color: rgb(0, 0, 255);">="ks2"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT&nbsp;*&nbsp;FROM&nbsp;STU<br />
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">sql:query</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">h3</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">学生情况</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">br</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TABLE&nbsp;</span><span style="color: rgb(255, 0, 0);">align</span><span style="color: rgb(0, 0, 255);">="center"</span><span style="color: rgb(255, 0, 0);">&nbsp;border</span><span style="color: rgb(0, 0, 255);">="1"</span><span style="color: rgb(255, 0, 0);">&nbsp;width</span><span style="color: rgb(0, 0, 255);">="95%"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">序号</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">学号</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">姓名</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">c:forEach&nbsp;</span><span style="color: rgb(255, 0, 0);">var</span><span style="color: rgb(0, 0, 255);">="row"</span><span style="color: rgb(255, 0, 0);">&nbsp;items</span><span style="color: rgb(0, 0, 255);">="${rs.rows}"</span><span style="color: rgb(255, 0, 0);">&nbsp;varStatus</span><span style="color: rgb(0, 0, 255);">="stat"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">${stat.count}</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">${row.stunum}</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">${row.stuname}</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">td</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">tr</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">c:forEach</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">TABLE</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
这样的页面似乎简洁多了,看着就一个字"清爽":)<br />
<br />
在这里还得补充一下,我是在JBOSS下做的,在&lt;sql:query&gt;标签里指定dataSource里碰到点问题,我的数据源是在jboss4\server\default\deploy\mysql-ds.xml里配置的,配置的数据源名字是ks,可在运行这个页面时总是提示找不到数据源,查了一些资料发现问题所在,要让JSTL能夠顺利使用JNDI的DataSource,还得在web.xml和jboss-web.xml里做修改,好让应用程序可以找到JNDI的服务,在/WEB-INF/下新建一文件jboss-web.xml,其内容如下<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jboss-web</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">ks</span><span style="color: rgb(0, 0, 255);">2&lt;/</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">java:ks</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jndi-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">jboss-web</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
然后在web.xml里加如下面的内容<br />
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">ks2</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-ref-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">javax.sql.DataSource</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-type</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Container</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">res-auth</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">resource-ref</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
这样处理之后,在JBOSS中使用JSTL数据源的问题就解决了<br />
刷新页面,希望看到的结果出来了,OK!<br />
今天终于体验一了下JSTL,真是酷哇,页面比以前写的简洁多了,看来得找个时间好好学习一下这个东东了<br />
<br />
<img src ="http://www.blogjava.net/zhouf/aggbug/227827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhouf/" target="_blank">ZhouFeng</a> 2008-09-08 23:10 <a href="http://www.blogjava.net/zhouf/articles/227827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>