﻿<?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-咖啡人生@CoffeeLife-文章分类-Tomcat</title><link>http://www.blogjava.net/dazern/category/7953.html</link><description>   天之道，利而不害；圣人之道，为而不争；信言不美，美言不信；善者不辩，辩者不善；知者不博，博者不知!
</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 12:17:56 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 12:17:56 GMT</pubDate><ttl>60</ttl><item><title>用eclipse + wtp 开发JSP(转) </title><link>http://www.blogjava.net/dazern/articles/34434.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Thu, 09 Mar 2006 03:06:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/34434.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/34434.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/34434.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/34434.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/34434.html</trackback:ping><description><![CDATA[<SPAN class=tpc_content><FONT size=2>作者:explorers <BR>源：</FONT><A href="http://blog.csdn.net/explorers/archive/2005/08/15/454769.aspx" target=_blank><FONT color=#663366 size=2>http://blog.csdn.net/explorers/archive/2005/08/15/454769.aspx</FONT></A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.eclipseworld.org/bbs/read.php?tid=680&amp;fpage=1&amp;toread=&amp;page=1">http://www.eclipseworld.org/bbs/read.php?tid=680&amp;fpage=1&amp;toread=&amp;page=1</A><BR><BR><FONT size=2>现在eclipse越来越好用了，随着sun jdk5.0的补丁4的推出，eclipse3.1也正式发布，<BR>二者结合，速度比以前快了很多。而wtp0.7 m5版本放出也有了一段时间，这个月月<BR>底可能wtp0.7会有release了。现在二者都基本成熟，用eclipse+wtp开发JSP是很方便<BR>的，但是关于wtp插件的配置和使用方面的文章却不多。很多人觉得wtp太麻烦，<BR>配不好不能用，本人一直用wtp开发jsp，常有朋友问相关的问题，所以写了这篇文章<BR>用来介绍WTP的配置和开发JSP的步骤。<BR>&nbsp; 这里介绍的主要是jdk5.0b4 + eclipse3.1 + wtp0.7m5环境下的配置和开发，<BR>其他版本有细微的差异，但是主要的过程是相同的。<BR>&nbsp; <BR>&nbsp; 1. 下载安装<BR>&nbsp; &nbsp; &nbsp; &nbsp; 这是当然的第一步啦，这里是连接:<BR>&nbsp; &nbsp; &nbsp; &nbsp; </FONT><A href="http://www.eclipse.org/webtools/index.html" target=_blank><FONT color=#663366 size=2>http://www.eclipse.org/webtools/index.html</FONT></A><BR><FONT size=2>&nbsp; &nbsp; 2. 配置<BR>有很多项需要配置，罗列如下:<BR>1) 配置java-buildpath<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32pIprGopCYnwj-Yl8ZpR43E5K4JHqCL96aXgABbiw1ZCLAeW3w2VMWNx9zzk-0Fjcl13qYWgnvoNopEncBHxQ4wdXs9e2wOu1LoQILSGcZlSg');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32pIprGopCYnwj-Yl8ZpR43E5K4JHqCL96aXgABbiw1ZCLAeW3w2VMWNx9zzk-0Fjcl13qYWgnvoNopEncBHxQ4wdXs9e2wOu1LoQILSGcZlSg" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>2) 配置JDK<BR>TOMCAT运行的时候需要JDK，eclipse自动找到的是jre，如下图:<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qCTnoB8wpYvBO1yXZsUgObtqvxrbLMvxpHDOJSxAJ1y9W8yupluLq9AqOLvlXC11b168Rk8bRre3RqSv660bEQ9u1sNWqUaksJ3F-hj_zEHw');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qCTnoB8wpYvBO1yXZsUgObtqvxrbLMvxpHDOJSxAJ1y9W8yupluLq9AqOLvlXC11b168Rk8bRre3RqSv660bEQ9u1sNWqUaksJ3F-hj_zEHw" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>3) 配置xml 和 internet 缓存<BR>在web应用中通常有很多的xml文件，默认情况下wtp会去验证这些xml文件，<BR>这就需要有这些xml文件的定义dtd或者xsd文件。<BR>wtp默认的会自动去下载，下载下来之后可以缓存之后供以后使用。<BR>所以首先我们要打开缓存功能。见下图，把disable cashing的勾去掉即可。<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qk0sgmfaAGWewE9bFIC1LtxQOK_CDAlHXC-1hkRHGO73LjHH4Kh4eEppRDydgtzIJBYjlrtfjGQ8bXie3Fj6kiN1vIOBpK3j9u4IXYK0f1Cw');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qk0sgmfaAGWewE9bFIC1LtxQOK_CDAlHXC-1hkRHGO73LjHH4Kh4eEppRDydgtzIJBYjlrtfjGQ8bXie3Fj6kiN1vIOBpK3j9u4IXYK0f1Cw" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>也可以把常用的xml文件的定义文件配置在xmlcatalog里边，<BR>这样进行xml验证的时候会自动使用这些文件，见下图：<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32o2i8fGQ73PXjq7BsIKops50Cxzs_7vj1iBAGtgokNck71mq8AfsqI0k1B3ShUiGH1KDDMtAV0BJbT8SOVBk_arQA8LZ8NnyzULBzgcEtLZjw');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32o2i8fGQ73PXjq7BsIKops50Cxzs_7vj1iBAGtgokNck71mq8AfsqI0k1B3ShUiGH1KDDMtAV0BJbT8SOVBk_arQA8LZ8NnyzULBzgcEtLZjw" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>实在不行，只有把xml自动验证去掉了，见Validation选项。 <BR>4) 配置tomcat服务器<BR>现在我们来配置tomcat，其他服务器的配置大致相同，如下图所示：<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qv8NJlwPr9HKQqXQZWfu6rvdIcgg_ayZ3H6pNcAOTZc218IuVRjjXnRnv3-q3YDDxFtI3ZHfEmRmllCmOaWT7Ibrj7ZvOIExqIpRJW4kbpuQ');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qv8NJlwPr9HKQqXQZWfu6rvdIcgg_ayZ3H6pNcAOTZc218IuVRjjXnRnv3-q3YDDxFtI3ZHfEmRmllCmOaWT7Ibrj7ZvOIExqIpRJW4kbpuQ" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>输入tomcat的路径和JDK<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qHfmZjLUAzO3JRTU8j1knz7uOhwZE4MrkB7xYug5-lxrfT9J3gZRF19dvPg3EkIQR0OYR1yuENx9XRjS13FkwxCo4EiLFA_UxRe8Fa0VZUXw');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32qHfmZjLUAzO3JRTU8j1knz7uOhwZE4MrkB7xYug5-lxrfT9J3gZRF19dvPg3EkIQR0OYR1yuENx9XRjS13FkwxCo4EiLFA_UxRe8Fa0VZUXw" onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>3 开发一个JSP<BR>首先new一个dynamic web project,在确定之后会提示是否进入j2ee <BR>perspective,选择否，进入java perspective,如下图：<BR>（说明：如果是以前的版本，在new的时候可能找不到dynamic web <BR>project,而是有一个Flexible project,那就先建一个Flexible project，<BR>然后在这个project下建立就可以找到dynamic web project了！）<BR>注意：第一次运行的时候，由于wtp需要验证web.xml这个文件，所以<BR>会去下载web.xml验证要用到的dtd或者xsd，所以速度比较慢，<BR>耐心等待，等所需要的文件全部下载下来之后以后就ok了。<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32pcLc7RQiT2MVYk_pEQfbDXsriHCrTyP5FXUoLhbqrvuUOxrOVrrTrSByQhEXhgo18nhkPAZV-Am3x1g5SwVBLDVbb_s7uI7C_FsdBS5Vp6SA');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32pcLc7RQiT2MVYk_pEQfbDXsriHCrTyP5FXUoLhbqrvuUOxrOVrrTrSByQhEXhgo18nhkPAZV-Am3x1g5SwVBLDVbb_s7uI7C_FsdBS5Vp6SA" onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>工程建好之后，在下面创建java class和一个jsp文件，如下图，<BR>注意目录结构：<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32oeEM79EO_JDBrm0yZtB13T7LLV0D_pdkaTOoN3HJdX-k4_q0wHBrsZFg202yaEfBw5M4NwkOrOiiMaHMbMrie-faKb5Yp6T6BHe-jHloOZsg');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32oeEM79EO_JDBrm0yZtB13T7LLV0D_pdkaTOoN3HJdX-k4_q0wHBrsZFg202yaEfBw5M4NwkOrOiiMaHMbMrie-faKb5Yp6T6BHe-jHloOZsg" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>上面图中的java类和jsp都创建好了，现在我们在tomcat中测试这个jsp<BR>页面，右击 webtests这个项目，在菜单中有一项run on server，点击<BR>后出来选择服务器的对话框，选择我们建立的tomcat服务器，然后添加<BR>项目，finish。wtp会在eclipse内打开一个浏览器打开这个项目。<BR>&nbsp; 注意到wtp自动新建并打开的工程servers，这个工程是在tomcat下<BR>测试jsp页面所必须要有的，而且必须是打开的状态，否则无法进行jsp<BR>测试。<BR><BR>4. 常见问题的解决<BR><BR>1) no server错误<BR>&nbsp; 这个错误在一些版本的wtp里边，就是一个红叉叉的对话框，说no<BR>server，此时请确认打开了servers这个工程。<BR><BR>2) 类未定义错误<BR>&nbsp; 如果你在web project中使用了一些外部的jar，比如说log4j之类，你<BR>可能在工程的classpath中已经添加了这个jar，但是运行时还会找不到类，<BR>这是因为这个jar没有被copy到工程的部署目录的 WEB-INF/lib目录下，<BR>显示 Navigator视图， 如下图。".deployables" 是一个web project<BR>被部署到的地方。把用到的jar 拷贝到lib下即可。<BR>（另一个解决办法是把jar拷贝到 /webtests/WebContent/WEB-INF/lib<BR>目录下，但是这样做有一个缺点，在你想要查看你用到的包中类的源码<BR>会比较麻烦。我的做法是把常用的包配置到user library中，设定好源码，<BR>再加入到工程的classpath中。如果把jar拷到<BR>/webtests/WebContent/WEB-INF/lib目录下，那么这个时候webtests<BR>这个工程的classpath中就有两份同样的包，在查看源码的时候都要选择，<BR>而且会以 /WEB-INF/lib下的包为优先，这可能跟classpath中的顺序有关，<BR>但是不方便。所以直接把jar拷到 .deployables目录下，可以解决这个<BR>问题。希望以后版本的wtp中能解决这样的问题，如果能够自动的把<BR>classpath中设置的所有jar都拷到 .deployables目录下就方便了。）<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32oxk5ghvk5y3OrY5xuhJPOjdZjr_fPQ90cgCvReoV6moMcY-XzUGbPQqCijJnr2xNCfZZZXRmJ0mi1LAkD_Dwy8rfr_lzj3tf2AyFWYB7iT4Q');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32oxk5ghvk5y3OrY5xuhJPOjdZjr_fPQ90cgCvReoV6moMcY-XzUGbPQqCijJnr2xNCfZZZXRmJ0mi1LAkD_Dwy8rfr_lzj3tf2AyFWYB7iT4Q" onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>3) context错误<BR>&nbsp; 有的时候会出现context错误，大致有两种，一种是context重复错误，<BR>这种情况下，tomcat无法启动。<BR>&nbsp; 在servers工程里，把server.xml中重复的context条目手工删除即可。<BR><IMG onclick="if(this.width>screen.width-461) window.open('http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32o8o9OKmds1_PvECU6vvOfQlVOwcqWOWL-ldaY8iMdrEBa5aMcSCxObP57EQrSkuQqgSunQM6m0XuivHtycj09s8G7puwc9gssjmUg64PLcYA');" src="http://storage.msn.com/x1p4JHjVbcjTC8uvvWweux05EdcB7I_ZJQ9NHijjZ4Z32o8o9OKmds1_PvECU6vvOfQlVOwcqWOWL-ldaY8iMdrEBa5aMcSCxObP57EQrSkuQqgSunQM6m0XuivHtycj09s8G7puwc9gssjmUg64PLcYA" width=564 onload="if(this.width>screen.width-460)this.width=screen.width-460;" border=0><BR>另一种错误是" no context"错误，这个时候tomcat可以启动，但是浏<BR>览器里边会说找不到页面，这就是说server.xml中没有这个context，解决<BR>的办法是在servers explorer视图中把server 删除，然后重新添加这个web<BR>应用，有时这样还不能解决可以重新配置server。</FONT><BR></SPAN><img src ="http://www.blogjava.net/dazern/aggbug/34434.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-03-09 11:06 <a href="http://www.blogjava.net/dazern/articles/34434.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat 5.5 的The Apache Tomcat Native library which allows optimal performance 的解决 </title><link>http://www.blogjava.net/dazern/articles/33862.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Mon, 06 Mar 2006 07:38:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/33862.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/33862.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/33862.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/33862.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/33862.html</trackback:ping><description><![CDATA[<P>Tomcat启动的时候出现下面这样的提示：</P>
<P>2006-1-26 19:44:11 org.apache.catalina.core.AprLifecycleListener lifecycleEvent<BR>信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Java\jdk1.5.0_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;d:\ruby\bin;.;..;D:\Java\jrockit-R26.0.0-jdk</P>
<P></P>
<P>实际这是建议使用apache的apr。</P>
<P>如果想使用apr的话， 实际操作很简单，</P>
<P>下载 <A href="http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll">http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll</A></P>
<P>将这个文件复制到C:\WINDOWS\system32\下面</P>
<P>然后重新启动tomcat，就会发现tomcat 的控制台信息为：<BR>2006-1-26 19:48:42 org.apache.coyote.http11.Http11AprProtocol init<BR>信息: Initializing Coyote HTTP/1.1 on http-9080</P>
<P></P>
<P></P>
<P>详情见 <A href="http://tomcat.apache.org/tomcat-5.5-doc/apr.html">http://tomcat.apache.org/tomcat-5.5-doc/apr.html</A></P>
<P><A href="http://www.google.com/search?hl=zh-CN&amp;newwindow=1&amp;q=The+Apache+Tomcat+Native+library+which+allows+optimal+performance&amp;btnG=%E6%90%9C%E7%B4%A2&amp;lr">http://www.google.com/search?hl=zh-CN&amp;newwindow=1&amp;q=The+Apache+Tomcat+Native+library+which+allows+optimal+performance&amp;btnG=%E6%90%9C%E7%B4%A2&amp;lr</A>=</P>
<P></P>
<P></P>
<P></P>
<P></P><BR><img src ="http://www.blogjava.net/dazern/aggbug/33862.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-03-06 15:38 <a href="http://www.blogjava.net/dazern/articles/33862.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat5.5配置经典教程——Configuring &amp; Using Apache Tomcat </title><link>http://www.blogjava.net/dazern/articles/32826.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Tue, 28 Feb 2006 04:31:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/32826.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/32826.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/32826.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/32826.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/32826.html</trackback:ping><description><![CDATA[<P align=left><STRONG><FONT color=#0000ff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=4>Configuring &amp; Using Apache Tomcat <BR></FONT></FONT></STRONG><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/"><FONT size=2>原文地址：http://www.coreservlets.com/Apache-Tomcat-Tutorial/</FONT></A><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG><FONT color=#006400>&nbsp; I</FONT></STRONG><A name=Introduction><STRONG><FONT color=#006400>ntroduction</FONT></STRONG></A></P>
<P>
<TABLE cellPadding=10 align=right>
<TBODY>
<TR>
<TH width=140><A href="http://www.coreservlets.com/"><IMG height=133 alt=CSAJSP src="http://www.coreservlets.com/images/CSAJSP2-Cover-100x133.jpg" width=100><BR><FONT color=#002c99>Core Servlets &amp;&nbsp;JSP 2/E</FONT></A></TH></TR>
<TR>
<TH width=140><A href="http://www.moreservlets.com/"><FONT color=#002c99><IMG height=140 alt=MSAJSP src="http://www.coreservlets.com/images/MSAJSP-Cover-105x140.jpg" width=105><BR>More Servlets &amp;&nbsp;JSP</FONT></A></TH></TR></TBODY></TABLE>Following is a guide to installing and configuring Apache Tomcat 5.5 for use as a <I>standalone</I> Web server (for development) that supports servlets 2.4 and JSP 2.0. (Note: Apache Tomcat is sometimes referred to as "<I>Jakarta</I> Tomcat" since the Apache <A href="http://jakarta.apache.org/"><FONT color=#002c99>Java effort</FONT></A> is known as "The Jakarta Project"). This Tomcat tutorial covers version 5.5.9; for coverage of older Tomcat versions (Apache Tomcat 5.0.<I>x</I> and Apache Tomcat 4.0.<I>x</I>), please see <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/Tomcat-5.0-and-4.0.html"><FONT color=#002c99>the Apache Tomcat 5.0 and 4.0 tutorial</FONT></A>. 
<P>Using Tomcat as a deployment server or integrating Tomcat as a plugin within the regular Apache server or a commercial Web server is more complicated than what is described in this tutorial. Although such integration is valuable for a deployment scenario (see <A href="http://jakarta.apache.org/tomcat/tomcat-5.5-doc/"><FONT color=#002c99>http://jakarta.apache.org/tomcat/tomcat-5.5-doc/</FONT></A>), my goal here is to show how to use Tomcat as a <I>development</I> server on your desktop. Regardless of what deployment server you use, you'll want a standalone server on your desktop to use for development. 
<P>The examples here assume you are using Windows, but they can be easily adapted for Linux, Solaris, and other versions of Unix. I've gotten many reports of successful use on MacOS X, but don't know the setup details. Except when I refer to specific Windows paths (e.g., <I>C:\blah\blah</I>), I use URL-style forward slashes for path separators (e.g., <I>install_dir/webapps/ROOT</I>). Adapt as necessary. 
<P>The information here is adapted from the introductory setup and configuration chapter of <I>Core Servlets and JavaServer Pages, 2nd Edition, Volume 1</I> from Sun Microsystems Press and Prentice Hall. For the book table of contents, index, source code, etc., please see <A href="http://volume1.coreservlets.com/"><FONT color=#002c99>http://volume1.coreservlets.com/</FONT></A>. For information on training courses (either at public venues or on-site at <I>your</I> company) taught by the author of the book and this Apache Tomcat tutorial, please see <A href="http://courses.coreservlets.com/"><FONT color=#002c99>this servlet, JSP, Struts, JSF, and Java training courses page</FONT></A>. To report errors or omissions in this writeup or to inquire about on-site training courses on servlets, JSP, Struts, JSF, and Java, please contact Marty Hall at <A href="mailto:hall@coreservlets.com"><FONT color=#002c99>hall@coreservlets.com</FONT></A>. <BR clear=all>
<P>
<TABLE width="100%" align=center>
<TBODY>
<TR>
<TH class=HEADING><A name=Summary>Executive Summary</A></TH></TR></TBODY></TABLE>
<P>
<TABLE width=200 align=right border=1>
<TBODY>
<TR>
<TH class=TABLE-HEADING align=middle>JSP, Servlet, Struts, &amp; JSF Training</TH></TR>
<TR>
<TD>Looking for hands-on training? Tired of inexperienced instructors teaching someone else's course materials? Want a choice of public or in-house courses? Check out these <A href="http://courses.coreservlets.com/"><FONT color=#002c99>servlet, JSP, Struts, and JSF training courses</FONT></A>. <BR>Distinctive features: 
<TABLE>
<TBODY>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD><I>Personally</I> developed and taught by <A href="http://courses.coreservlets.com/#Instructor"><FONT color=#002c99>Marty Hall</FONT></A>, an experienced developer, award-winning instructor, 4-time JavaOne speaker, and author of <I>Core Servlets and JSP</I>, <I>More Servlets and JSP</I>, and this Apache Tomcat tutorial.</TD></TR>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD>A choice of <A href="http://courses.coreservlets.com/"><FONT color=#002c99>on-site training courses at <I>your</I> organization</FONT></A> or <A href="http://courses.coreservlets.com/public-courses/"><FONT color=#002c99>training courses at public venues</FONT></A>.</TD></TR>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD>Well-tested, having been used by Marty for courses for more than 100 different organizations in the USA, Canada, Australia, Japan, Puerto Rico, and the Philippines.</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>I give extremely detailed instructions in the following sections. If you're pretty experienced and just want a short summary, this section will probably be enough for you. You can also <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>download a preconfigured Apache Tomcat version</FONT></A> that incorporates all of the modifications of this tutorial and includes a sample development directory, shortcuts, and <I>autoexec.bat</I> file. 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Install-JDK"><FONT color=#002c99>Install the JDK.</FONT></A> Make sure JDK 1.4 or 1.5 is installed and your <CODE>PATH</CODE> is set so that <U>both</U> "<CODE>java -version</CODE>" and "<CODE>javac -help</CODE>" give a result. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Configure-Tomcat"><FONT color=#002c99>Configure Tomcat.</FONT></A> 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Download-Tomcat"><FONT color=#002c99>Download the software.</FONT></A> Go to <A href="http://jakarta.apache.org/site/binindex.cgi#tomcat"><FONT color=#002c99>http://jakarta.apache.org/site/binindex.cgi#tomcat</FONT></A> and download and unpack the zip file for the current release build of Tomcat 5.5. If you use Tomcat 5.5 with JDK 1.4 (recommended), you have to also download and unpack the "Compat" zip file. Also see the <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>preconfigured Apache Tomcat version</FONT></A>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Java-Home"><FONT color=#002c99>Set the <CODE>JAVA_HOME</CODE> variable.</FONT></A> Set it to refer to the base JDK directory, not the <I>bin</I> subdirectory. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Change-Port"><FONT color=#002c99>Change the port to 80.</FONT></A> Edit <I>install_dir/conf/<B>server</B>.xml</I> and change the <CODE>port</CODE> attribute of the <CODE>Connector</CODE> element from 8080 to 80. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Servlet-Reloading"><FONT color=#002c99>Turn on servlet reloading.</FONT></A> Edit <I>install_dir/conf/<B>context</B>.xml</I> and change <CODE>&lt;Context&gt;</CODE> to <CODE>&lt;Context&nbsp;reloadable="true"&gt;</CODE>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Enable-Invoker"><FONT color=#002c99>Enable the invoker servlet.</FONT></A> Go to <I>install_dir/conf/<B>web</B>.xml</I> and uncomment the <CODE>servlet</CODE> and <CODE>servlet-mapping</CODE> elements that map the <CODE>invoker</CODE> servlet to <I>/servlet/*</I>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#DOS-Memory"><FONT color=#002c99>Change the DOS memory settings.</FONT></A> If you are on Windows 98/Me and get an "Out of Environment Space" error message when you start the server, right-click on <I>install_dir/bin/startup.bat</I>, select Properties, select Memory, and change the Initial Environment entry from Auto to at least 2816. Repeat the process for <I>install_dir/bin/shutdown.bat</I>. <U>Not</U> necessary on recent version of Windows. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Catalina-Home"><FONT color=#002c99>Set the <CODE>CATALINA_HOME</CODE> variable.</FONT></A> Optionally, set <CODE>CATALINA_HOME</CODE> to refer to the top-level Tomcat installation directory. <U>Not</U> necessary unless you copy the startup scripts instead of making shortcuts to them. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>Use a preconfigured Tomcat version.</FONT></A> Optionally, use a version of Jakarta Tomcat that has all of the above changes already made, and has the test HTML, JSP, and servlet files already bundled. </LI></OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test-Server"><FONT color=#002c99>Test the server.</FONT></A> 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Start-Server"><FONT color=#002c99>Verify that you can start the server.</FONT></A> Double-click <I>install_dir/bin/startup.bat</I> and try accessing <I>http://localhost/</I>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Try-Pages"><FONT color=#002c99>Check that you can access your own HTML &amp; JSP pages.</FONT></A> Drop some simple HTML and JSP pages into <I>install_dir/webapps/ROOT</I> and access them with <I>http://localhost/filename</I>. </LI></OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Development-Environment"><FONT color=#002c99>Set up your development environment.</FONT></A> 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Development-Directory"><FONT color=#002c99>Create a development directory.</FONT></A> Put it anywhere except within the Tomcat installation hierarchy. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Shortcuts"><FONT color=#002c99>Make shortcuts to the Tomcat startup &amp; shutdown Scripts.</FONT></A> Put shortcuts to <I>install_dir/bin/startup.bat</I> and <I>install_dir/bin/shutdown.bat</I> in your development directory and/or on your desktop. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Set-CLASSPATH"><FONT color=#002c99>Set your <CODE>CLASSPATH</CODE>.</FONT></A> Include the current directory ("."), the servlet/JSP JAR files (<I>install_dir/common/lib/servlet-api.jar</I> and <I>install_dir/common/lib/jsp-api.jar</I>), and your main development directory from Step 1. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Bookmark-API"><FONT color=#002c99>Bookmark the servlet &amp; JSP javadocs.</FONT></A> Add <I>install_dir/webapps/tomcat-docs/servletapi/index.html</I> and <I>install_dir/webapps/tomcat-docs/jspapi/index.html</I> to your bookmarks/favorites list. </LI></OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test-Servlets"><FONT color=#002c99>Compile and test some simple servlets.</FONT></A> 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test1"><FONT color=#002c99>Test a packageless servlet.</FONT></A> Compile a simple servlet, put the <I>.class</I> file in <I>install_dir/webapps/ROOT/WEB-INF/classes</I>, and access it with <I>http://localhost/servlet/ServletName</I>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test2"><FONT color=#002c99>Test a servlet that uses packages.</FONT></A> Compile the servlet, put the <I>.class</I> file in <I>install_dir/webapps/ROOT/WEB-INF/classes/packageName</I>, and access it with <I>http://localhost/servlet/packageName.ServletName</I>. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test3"><FONT color=#002c99>Test a servlet that uses packages and utility classes.</FONT></A> Compile a servlet, put both the servlet <I>.class</I> file and the utility file <I>.class</I> file in <I>install_dir/webapps/ROOT/WEB-INF/classes/packageName</I>, and access the servlet with <I>http://localhost/servlet/packageName.ServletName</I>. This third step verifies that the <CODE>CLASSPATH</CODE> includes the top level of your development directory. </LI></OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Simplify-Deployment"><FONT color=#002c99>Establish a simplified deployment method.</FONT></A> 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Copy-to-Shortcut"><FONT color=#002c99>Copy to a shortcut.</FONT></A> Make a shortcut to <I>install_dir/webapps/ROOT</I>. Copy packageless <I>.class</I> files directly there. With packages, copy the entire directory there. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Use-minus-d"><FONT color=#002c99>Use the <CODE>-d</CODE> option of <CODE>javac</CODE>.</FONT></A> Use <CODE>-d</CODE> to tell Java where the deployment directory is. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Use-IDE"><FONT color=#002c99>Let your IDE take care of deployment.</FONT></A> Tell your IDE where the deployment directory is and let it copy the necessary files. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Use-ant"><FONT color=#002c99>Use <CODE>ant</CODE> or a similar tool.</FONT></A> Use the Apache <CODE>make</CODE>-like tool to automate copying of files. </LI></OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#More-Info"><FONT color=#002c99>Get more info.</FONT></A> Access the complete set of Tomcat docs, get free JSP and servlet tutorials, read the official servlet and JSP specifications, get JSP-savvy editors and IDEs, look for J2EE jobs, etc. </LI></OL>
<P>
<TABLE width="100%" align=center>
<TBODY>
<TR>
<TH class=HEADING><A name=Install-JDK>Install the JDK</A></TH></TR></TBODY></TABLE>
<P>Your first step is to download and install Java. The servlet 2.4 (JSP 2.0) specification requires JDK 1.3 or later; J2EE 1.4 (which includes servlets 2.4 and JSP 2.0) requires JDK 1.4 or later. You might as well get a recent Java version, so use JDK 1.4 or 1.5. If you know which of those Java versions will be used on your project, get that one. If not, I recommend JDK 1.4 instead of JDK 1.5 so that you don't limit portability by accidentally using Java 1.5 features in your code. See the following sites for download and installation information. 
<UL>
<LI><B>JDK 1.4 for Windows, Linux, and Solaris:</B> <A href="http://java.sun.com/j2se/1.4/download.html"><FONT color=#002c99>http://java.sun.com/j2se/1.4/download.html</FONT></A>. Be sure you download the full SDK (Software Development Kit), not just the JRE (Java Runtime Environment). The JRE is only for running already-compiled <I>.class</I> files, and lacks a compiler. 
<LI><B>JDK 1.5 for Windows, Linux, and Solaris:</B> <A href="http://java.sun.com/j2se/1.5.0/download.jsp"><FONT color=#002c99>http://java.sun.com/j2se/1.5.0/download.jsp</FONT></A>. Be sure you download the full JDK (J2SE Development Kit), not just the JRE (Java Runtime Environment). The JRE is only for running already-compiled <I>.class</I> files, and lacks a compiler. 
<LI><B>JDK 1.4 for MacOS:</B> <A href="http://developer.apple.com/java/"><FONT color=#002c99>http://developer.apple.com/java/</FONT></A>. </LI></UL>
<P>Once you've installed Java, confirm that everything including your <CODE>PATH</CODE> is configured properly by opening a DOS window and typing "<CODE>java -version</CODE>" <I>and</I> "<CODE>javac -help</CODE>". You should see a real result both times, not an error message about an unknown command. Or, if you use an IDE, compile and run a simple program to confirm that the IDE knows where you installed Java. </P>
<P>
<TABLE width="100%" align=center>
<TBODY>
<TR>
<TH class=HEADING><A name=Configure-Tomcat>Configure Tomcat</A></TH></TR></TBODY></TABLE>
<P>
<TABLE width=200 align=right border=1>
<TBODY>
<TR>
<TH class=TABLE-HEADING align=middle>JSP, Servlet, Struts, &amp; JSF Training</TH></TR>
<TR>
<TD>Looking for hands-on training? Tired of inexperienced instructors teaching someone else's course materials? Want a choice of public or in-house courses? Check out these <A href="http://courses.coreservlets.com/"><FONT color=#002c99>servlet, JSP, Struts, and JSF training courses</FONT></A>. <BR>Distinctive features: 
<TABLE>
<TBODY>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD><I>Personally</I> developed and taught by <A href="http://courses.coreservlets.com/#Instructor"><FONT color=#002c99>Marty Hall</FONT></A>, an experienced developer, award-winning instructor, 4-time JavaOne speaker, and author of <I>Core Servlets and JSP</I>, <I>More Servlets and JSP</I>, and this Apache Tomcat tutorial.</TD></TR>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD>A choice of <A href="http://courses.coreservlets.com/"><FONT color=#002c99>on-site training courses at <I>your</I> organization</FONT></A> or <A href="http://courses.coreservlets.com/public-courses/"><FONT color=#002c99>training courses at public venues</FONT></A>.</TD></TR>
<TR>
<TD vAlign=top align=middle width=5>•</TD>
<TD>Well-tested, having been used by Marty for courses for more than 100 different organizations in the USA, Canada, Australia, Japan, Puerto Rico, and the Philippines.</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>Configuring Tomcat involves five main steps and four optional steps: 
<OL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Download-Tomcat"><FONT color=#002c99>Downloading the Jakarta Tomcat software.</FONT></A> 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Java-Home"><FONT color=#002c99>Setting the <CODE>JAVA_HOME</CODE> variable.</FONT></A> 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Change-Port"><FONT color=#002c99>Changing the port from 8080 to 80.</FONT></A> 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Servlet-Reloading"><FONT color=#002c99>Telling Tomcat to reload servlets when they are modified. </FONT></A>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Enable-Invoker"><FONT color=#002c99>Enabling the invoker servlet</FONT></A> 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#DOS-Memory"><FONT color=#002c99>Changing the DOS memory settings.</FONT></A> (Win98/Me only) 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Catalina-Home"><FONT color=#002c99>Setting the <CODE>CATALINA_HOME</CODE> variable.</FONT></A> (Optional; rarely used) 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>Using a preconfigured version of Tomcat with these changes already made.</FONT></A> (Optional; widely used) 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#EXE-Installer"><FONT color=#002c99>Using the Windows .exe installer instead of the .zip file (Not Recommended)</FONT></A> </LI></OL>
<P>Details of each step are given below. If Tomcat is already running, restart it after performing these steps. </P>
<H2><A name=Download-Tomcat>1. Download the Apache Tomcat Software</A></H2>
<P>Go to <A href="http://jakarta.apache.org/site/binindex.cgi#tomcat"><FONT color=#002c99>http://jakarta.apache.org/site/binindex.cgi#tomcat</FONT></A> and download the zip file for the current release build of Jakarta Tomcat 5.5. If you need to use an older version of Tomcat to be compatible with an app server such as BEA WebLogic 8.1 that does not support JSP 2.0, please see the older <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/Tomcat-5.0-and-4.0.html"><FONT color=#002c99>Apache Tomcat 5.0 and 4.0 tutorial</FONT></A>. </P>
<P><B>Note that if you use Tomcat 5.5 with JDK 1.4 (the recommended setup for most users), you have to download <I>both</I> the main zip file and the "Compat" zip file.</B> If you use Tomcat 5.5 with JDK 1.5, you do not need the "Compat" zip file, but it is better to use JDK 1.4 (unless you will deploy on JDK 1.5 only) so that you do not limit portability by accidentally using JDK 1.5 constructs in your Java code. 
<P>Save the zip file(s) on your PC and unzip into a location of your choice. You specify the top-level directory (e.g., <I>C:\</I>) and the zip file has embedded subdirectories (e.g., <I>jakarta-tomcat-5.5.9</I>). Thus, <I>C:\jakarta-tomcat-5.5.9</I> is a common resultant installation directory. Note: from this point forward, I'll refer to that location as <I>install_dir</I>. For Windows, there is also a .exe installer; I prefer the .zip file, but see <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#EXE-Installer"><FONT color=#002c99>the .exe installer section</FONT></A> for notes on the differences between the two. 
<P>Alternatively, you can use my <A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>preconfigured Jakarta Tomcat version</FONT></A>. This version already has the port changed to 80, servlet reloading enabled, the invoker servlet turned on, and the "Compat" package included. It also comes with a sample development directory and <I>autoexec.bat</I> file. 
<H2><A name=Java-Home>2. Set the <CODE>JAVA_HOME</CODE> Variable</A></H2>
<P>Next, you must set the <CODE>JAVA_HOME</CODE> environment variable to tell Tomcat where to find Java. Failing to properly set this variable prevents Tomcat from compiling JSP pages. This variable should list the base JDK installation directory, not the <I>bin</I> subdirectory. For example, on almost any version of Windows, if you installed the JDK in <I>C:\j2sdk1.4.2_08</I>, you might put the following line in your <I>C:\autoexec.bat</I> file. <PRE>  set JAVA_HOME=C:\j2sdk1.4.2_08
</PRE>
<P>On Windows XP, you could also go to the Start menu, select Control Panel, choose System, click on the Advanced tab, press the Environment Variables button at the bottom, and enter the <CODE>JAVA_HOME</CODE> variable and value directly. On Windows 2000 and NT, you do Start, Settings, Control Panel, System, then Environment. However, you can use <I>C:\autoexec.bat</I> on those versions of Windows also (unless a system administrator has set your PC to ignore it). </P>
<H2><A name=Change-Port>3. Change the Port to 80</A></H2>
<P>Assuming you have no other server already running on port 80, you'll find it convenient to configure Tomcat to run on the default HTTP port (80) instead of the out-of-the-box port of 8080. Making this change lets you use URLs of the form <I>http://localhost/blah</I> instead of <I>http://localhost:8080/blah</I>. Note that you need admin privileges to make this change on Unix/Linux. Also note that some versions of Windows XP automatically start IIS on port 80. So, if you use XP and want to use port 80 for Tomcat, you may need to disable IIS (see the Administrative Tools section of the Control Panel). </P>
<P>To change the port, edit <I>install_dir/conf/<B>server</B>.xml</I> and change the <CODE>port</CODE> attribute of the <CODE>Connector</CODE> element from 8080 to 80, yielding a result similar to that below. <PRE>    &lt;Connector <B>port="80"</B> ...
      maxThreads="150" minSpareThreads="25" ...
</PRE>
<P>You can also: </P>
<UL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>Use my preconfigured Jakarta Tomcat version.</FONT></A> Apache Tomcat 5.5.9 with all <I>server.xml</I>, <I>context.xml</I>, and <I>web.xml</I> changes, plus the sample HTML, JSP, Java files. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat5.5-files/server.xml"><FONT color=#002c99>Download my modified server.xml for Tomcat 5.5.</FONT></A> From Apache Tomcat 5.5.9, but should work on most versions of Tomcat 5.5. Right-click or shift-click on the link to download the file. </LI></UL>
<H2><A name=Servlet-Reloading>4. Turn on Servlet Reloading</A></H2>
<P>The next step is to tell Tomcat to check the modification dates of the class files of requested servlets, and reload ones that have changed since they were loaded into the server's memory. This slightly degrades performance in deployment situations, so is turned off by default. However, if you fail to turn it on for your development server, you'll have to restart the server every time you recompile a servlet that has already been loaded into the server's memory. Since this tutorial discusses the use of Tomcat for <I>development</I>, this change is strongly recommended. </P>
<P>To turn on servlet reloading, edit Edit <I>install_dir/conf/<B>context</B>.xml</I> and change <PRE>  &lt;Context&gt;</PRE>
<P>to </P><PRE>  &lt;Context&nbsp;reloadable="true"&gt;</PRE>
<P>You can also: </P>
<UL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>Use my preconfigured Tomcat version.</FONT></A> Tomcat 5.5.9 with all server.xml, context.xml, and web.xml changes, plus the sample HTML, JSP, Java files. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat5.5-files/context.xml"><FONT color=#002c99>Download my modified context.xml for Tomcat 5.5.</FONT></A> From Tomcat 5.5.9, but should work on most versions of Tomcat 5.5. Right-click or shift-click on the link to download the file. </LI></UL>
<H2><A name=Enable-Invoker>5. Enable the Invoker Servlet</A></H2>
<P>The invoker servlet lets you run servlets without first making changes to your Web application's deployment descriptor (i.e., the <I>WEB-INF/web.xml</I> file). Instead, you just drop your servlet into <I>WEB-INF/classes</I> and use the URL <I>http://host/<B>servlet</B>/<B>ServletName</B></I> (or <I>http://host/webAppName/servlet/ServletName</I> once you start using your own Web applications; see Section 2.11 of <A href="http://volume1.coreservlets.com/"><FONT color=#002c99>the book</FONT></A> for details on Web apps). The invoker servlet is extremely convenient when you are learning and even when you are doing your initial development. You almost certainly want to enable it when learning, <U>but you should disable it again before deploying any real applications</U>. </P>
<P>To enable the invoker servlet, uncomment the following <CODE>servlet</CODE> and <CODE>servlet-mapping</CODE> elements in <I>install_dir/conf/<B>web</B>.xml</I>. Do not confuse this Apache Tomcat-specific <I>web.xml</I> file with the standard one that goes in the <I>WEB-INF</I> directory of each Web application. <PRE>    &lt;servlet&gt;
        &lt;servlet-name&gt;invoker&lt;/servlet-name&gt;
        &lt;servlet-class&gt;
          org.apache.catalina.servlets.InvokerServlet
        &lt;/servlet-class&gt;
        ...
    &lt;/servlet&gt;
    ...
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;invoker&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/servlet/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
</PRE>
<P>You can also: </P>
<UL>
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Preconfigured-Tomcat"><FONT color=#002c99>Use my preconfigured Tomcat version.</FONT></A> Tomcat 5.5.9 with all <I>server.xml</I>, <I>context.xml</I>, and <I>web.xml</I> changes, plus the sample HTML, JSP, Java files. 
<LI><A href="http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat5.5-files/web.xml"><FONT color=#002c99>Download my modified web.xml for Tomcat 5.5.</FONT></A> From Tomcat 5.5.9, but should work on most versions of Tomcat 5.5. Right-click or shift-click on the link to download the file. </LI></UL>
<H2><A name=DOS-Memory>6. Change DOS Memory Settings (Win 98/Me Only)</A></H2>
<P>If you use Windows 98/Me, you may also have to change the DOS memory settings for the startup and shutdown scripts. If you get an "Out of Environment Space" error message when you start the server, you will need to right-click on <I>install_dir/bin/startup.bat</I>, select Properties, select Memory, and change the Initial Environment entry from Auto to at least 2816. Repeat the process for <I>install_dir/bin/shutdown.bat</I>. This step is not necessary in more recent versions of Windows. </P>
<H2><A name=Catalina-Home>7. Set the <CODE>CATALINA_HOME</CODE> Variable (Optional)</A></H2>
<P>If you are going to make copies of the Tomcat startup or shutdown scripts (e.g., <I>startup.bat</I> and <I>shutdown.bat</I>), it is also helpful to set the <CODE>CATALINA_HOME</CODE> environment variable to refer to the top-level directory of the Apache Tomcat installation (e.g., <I>C:\jakarta-tomcat-5.5.9<%2<img src ="http://www.blogjava.net/dazern/aggbug/32826.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-02-28 12:31 <a href="http://www.blogjava.net/dazern/articles/32826.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat 5.5.15相关配置 </title><link>http://www.blogjava.net/dazern/articles/32776.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Tue, 28 Feb 2006 00:51:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/32776.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/32776.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/32776.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/32776.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/32776.html</trackback:ping><description><![CDATA[<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=0 cellPadding=3 width="98%" align=center border=0>
<TBODY>
<TR>
<TD align=middle colSpan=2>作者: hasek &nbsp; 发表日期: 2006-02-21 00:08 &nbsp; <A title=http://www.hnlinux.net/blog/article.php?tid_218.html onclick="clipboardData.setData('Text','http://www.hnlinux.net/blog/article.php?tid_218.html')" href="javascript:"><FONT color=#5c5a5b>复制链接</FONT></A> </TD></TR>
<TR>
<TD class=content colSpan=2><BR><BR>
<P>&nbsp;&nbsp;&nbsp;&nbsp; Tomcat作为一个很优秀的web application server的确值得大家使用,特别是熟悉java的爱好者,不过它的配置并不象它的应用那么优秀,至少在配置上有很多琐碎的事情要做,现在我将我自己配置最新的tomcat5.5.15的一点心得告诉大家:<BR><BR>总共涉及三个方面,也是tomcat配置比较烦琐的地方<BR><BR>一.与apache的配置(暂略,晚点再将配置详细介绍)</P>
<P>二.使tomcat5.5.15支持jstl标签<BR>&nbsp;&nbsp;&nbsp; 这个是最简单的配置,只要按照以下方法,就可以配置成功.<BR>&nbsp;&nbsp;&nbsp; 1.下载 jakarta-taglibs-standard-1.1.2.zip (windows)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jakarta-taglibs-standard-1.1.2.tar.gz(linux)<BR>&nbsp;&nbsp;&nbsp; 2.解压在解压的lib目录下找到jstl.jar,standard.jar这两个.jar文件,将他们复制到 你的站点/WEB-INF/lib文件夹下,在tld目录下将所有的.tld文件复制到 你的站点/WEB-INF/taglib/文件下<BR>&nbsp;&nbsp;&nbsp; 3.配置 你的站点/WEB-INF/web.xml文件,在&lt;/webapp&gt;前添加如下内容<BR>&nbsp; &lt;taglib&gt;<BR>&nbsp; &lt;taglib-uri&gt;<A href="http://www.hnlinux.net/core</taglib-uri>" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net/core&lt;/taglib-uri&gt;</FONT></A><BR>&nbsp; &lt;taglib-location&gt;/WEB-INF/taglibs/c.tld&lt;/taglib-location&gt;<BR>&nbsp; &lt;/taglib&gt;<BR><BR>&nbsp; &lt;taglib&gt;<BR>&nbsp; &lt;taglib-uri&gt;<A href="http://www.hnlinux.net/fn</taglib-uri>" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net/fn&lt;/taglib-uri&gt;</FONT></A><BR>&nbsp; &lt;taglib-location&gt;/WEB-INF/taglibs/fn.tld&lt;/taglib-location&gt;<BR>&nbsp; &lt;/taglib&gt;<BR><BR>&nbsp; &lt;taglib&gt;<BR>&nbsp; &lt;taglib-uri&gt;<A href="http://www.hnlinux.net/sql</taglib-uri>" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net/sql&lt;/taglib-uri&gt;</FONT></A><BR>&nbsp; &lt;taglib-location&gt;/WEB-INF/taglibs/sql.tld&lt;/taglib-location&gt;<BR>&nbsp; &lt;/taglib&gt;<BR><BR>&nbsp; &lt;taglib&gt;<BR>&nbsp; &lt;taglib-uri&gt;<A href="http://www.hnlinux.net/fmt</taglib-uri>" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net/fmt&lt;/taglib-uri&gt;</FONT></A><BR>&nbsp; &lt;taglib-location&gt;/WEB-INF/taglibs/fmt.tld&lt;/taglib-location&gt;<BR>&nbsp; &lt;/taglib&gt;<BR>(注意我的&lt;taglib-uri&gt;引用了<A href="http://www.hnlinux.net/"><A href="http://www.hnlinux.net/" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net</FONT></A></A>,呵呵,所以大家如果按照这样设置的话,在jsp中引用jstl标签是记得采用这样写&lt;%@ taglib uri=<A href="http://www.hnlinux.net/core"><A href="http://www.hnlinux.net/core" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net/core</FONT></A></A> prefix="c" %&gt;,可见这里配置是很灵活的随便你取什么名字,只要在写jsp的时候相对应就可以)<BR><BR>现在你就可以使用jstl来书写你的jsp了.<BR><BR>三.连接mysql数据库的配置<BR>&nbsp;&nbsp; 1.下载 mysql-connector-java-5.0.0-beta.zip 将mysql-connector-java-5.0.0-beta-bin.jar复制到$Tomcat_home$/common/lib文件夹，（如果你不想使用数据连接池的话，可以放在　你的站点/WEB-INF/lib文件夹下）<BR>　2.搞定了，你现在就可以使用连接数据库的的相关语句了（这个是最简单的，呵呵）<BR><BR>四．mysql连接池的配置．<BR>　1.下载commons-dbcp-1.2.1.zip　解压将commons-dbcp-1.2.1.jar复制到$Tomcat_home$/common/lib下（保证mysql的jdbc的驱动也在此目录）<BR>　2.修改$Tomcat_home$/cof/server.xml在context标签内添加以下内容，如果没有找到context标签，注意在下面加上红色的部分，兰色部分根据自己情况修改，不用解释了吧？<BR><FONT color=#ff0000>&lt;Context path="/hasek" docBase="hasek"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; debug="5" reloadable="true" crossContext="true"&gt;<BR></FONT>&nbsp; &lt;Resource name="<FONT color=#1111ee>hasek</FONT>" auth="Container" type="javax.sql.DataSource"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxActive="100" maxIdle="30" maxWait="10000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username="<FONT color=#0000ff>root</FONT>" password="<FONT color=#1111ee>root</FONT>" driverClassName="com.mysql.jdbc.Driver"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url="jdbc:mysql://localhost:3306/<FONT color=#1111ee>hasek</FONT>?autoReconnect=true"/&gt;</P>
<P><FONT color=#ff0000>&lt;/Context&gt;<BR>注意一点的事情是：&lt;Context path="/hasek" docBase="hasek"．．．　中/hasek代表的是　你的站点<BR><FONT color=#000000>&lt;Resource name="</FONT><FONT color=#1111ee>hasek</FONT></FONT><FONT color=#000000>"　这个hasek代表的是你的连接池的名字，这个要和下面的web.xml里的内容相一致．<BR>url="jdbc:mysql://localhost:3306/<FONT color=#1111ee>hasek</FONT>?autoReconnect=true"/&gt;中的hasek代表你的数据库名字<BR><BR>3.修改　你的站点/WEB-INF/web.xml　在&lt;/webapp&gt;标签前添加以下内容：<BR><BR>&nbsp; &lt;description&gt;MySQL Test App&lt;/description&gt;<BR>&nbsp; &lt;resource-ref&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;DB Connection&lt;/description&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;res-ref-name&gt;<FONT color=#421ae6>hasek</FONT>&lt;/res-ref-name&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;res-auth&gt;Container&lt;/res-auth&gt;<BR>&nbsp; &lt;/resource-ref&gt;<BR>&nbsp;4.测试代码（连接池与jstl标签测试）test.jsp<BR><BR>&lt;%@ taglib uri="<A href="http://www.hnlinux.net/" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net</FONT></A>/sql" prefix="sql" %&gt;<BR>&lt;%@ taglib uri="<A href="http://www.hnlinux.net/" target=_blank><FONT color=#5c5a5b>http://www.hnlinux.net</FONT></A>/core" prefix="c" %&gt;</FONT></P>
<P><FONT color=#000000>&lt;sql:query var="rs" dataSource="hasek"&gt;<BR>select * from hasek<BR>&lt;/sql:query&gt;</FONT></P>
<P><FONT color=#000000>&lt;html&gt;<BR>&nbsp; &lt;head&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;DB Test&lt;/title&gt;<BR>&nbsp; &lt;/head&gt;<BR>&nbsp; &lt;body&gt;</FONT></P>
<P><FONT color=#000000>&nbsp; &lt;h2&gt;测试成功&lt;/h2&gt;<BR>&nbsp; <BR>&lt;c:forEach var="row" items="${rs.rows}"&gt;<BR>&nbsp;&nbsp;&nbsp; Foo ${row.id}&lt;br/&gt;<BR>&nbsp;&nbsp;&nbsp; Bar ${row.num}&lt;br/&gt;<BR>&lt;/c:forEach&gt;</FONT></P>
<P><FONT color=#000000>&nbsp; &lt;/body&gt;<BR>&lt;/html&gt;<BR>5.输入<A href="http://localhost:8080/hasek/test.jsp"><A href="http://localhost:8080/hasek/test.jsp" target=_blank><FONT color=#5c5a5b>http://localhost:8080/hasek/test.jsp</FONT></A></A>看到测试成功字样就说明你配置ok了</FONT></P></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/dazern/aggbug/32776.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-02-28 08:51 <a href="http://www.blogjava.net/dazern/articles/32776.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转载]Tomcat 5.5.15 和SQLServer2000 SP3的连接池</title><link>http://www.blogjava.net/dazern/articles/32727.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Mon, 27 Feb 2006 12:44:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/32727.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/32727.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/32727.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/32727.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/32727.html</trackback:ping><description><![CDATA[<P>Tomcat 5.5.15 和SQLServer2000 SP3基于SQLServer2000JDBC SP3 的连接池配制<BR>一、准备<BR>需要下载：<BR>1．&nbsp;tomcat5.5.15<BR>2．&nbsp;Tomcat5.5.15admin<BR>3．&nbsp;SQLServer2000JDBC SP3或者jtds</P>
<P>安装tomcat。并添加admin角色和用户。<BR>将jdbc驱动包放到tomcat_home\common\lib目录下。<BR>在MyEclipse建立一个新的Web项目。使用刚才配置的tomcat作为服务器。</P>
<P>启动tomcat。</P>
<P>二、配置<BR>打开tomcat。<BR>&nbsp;<BR>登录 Tomcat Web Server Administration Tool.</P>
<P><BR>点击左侧的Data Sources。<BR>&nbsp;<BR>在右侧Available Actions下拉菜单中选择Create New Data Source.<BR>&nbsp;<BR>输入<BR>JNDI Name：<BR>Data Source URL：<BR>JDBC Driver Class：<BR>User Name：<BR>Password：<BR>Max.Active Connections：最大活动连结数 ，0为不限 。<BR>Max.Idle Connections：最大等待连结数 ，0为不限 。<BR>Max.Wait for Connection：建立连接超时时间ms,-1为无限 。</P>
<P>注：使用SQLServer的官方JDBC驱动，Class=com.microsoft.jdbc.sqlserver.SQLServerDriver，URL=jdbc:Microsoft:sqlserver://127.0.0.1:1433;databaseName=aa；使用开源的驱动Jtds，Class=net.sourceforge.jtds.jdbc.sqlserver，URL=jdbc:jtds:sqlserver://127.0.0.1:1433/aa</P>
<P>输入完毕，点击“Save”按钮保存。<BR>&nbsp;<BR>点击页面右上侧“Commit Changes”按钮，保存刚才的设置。（这一步很重要哦！）</P>
<P>打开tomcat_home\conf\server.xml的&lt; GlobalNamingResources&gt;&lt;/ GlobalNamingResources&gt;中找到</P>
<P>&nbsp;&nbsp;&nbsp; &lt;Resource<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="jdbc/mydbcp"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="javax.sql.DataSource"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password="aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxIdle="2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxWait="5000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username="aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url="jdbc:microsoft:sqlserver://10.0.2.37:1433;databaseName=aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxActive="4"/&gt;<BR>这是JNDI的主要配置文件，可以不使用图形界面直接写入server.xml中。<BR>在tomcat_home\webapps\dbcp\ META-INF\context.xml的&lt;context&gt;&lt;/context&gt;中填入上面的代码。<BR>如果更改了JNDI，则必须手动更改context.xml。</P>
<P>&nbsp;&nbsp;&nbsp; &lt;Resource<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="mydbcp" 注：此处不同<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type="javax.sql.DataSource"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password="aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxIdle="2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxWait="5000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username="aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url="jdbc:microsoft:sqlserver://10.0.2.37:1433;databaseName=aa"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxActive="4"/&gt;<BR>和<BR>&nbsp; &lt;ResourceLink<BR>&nbsp;&nbsp;&nbsp; global="jdbc/mydbcp"<BR>&nbsp;&nbsp;&nbsp; name="jdbc/mydbcp"<BR>type="javax.sql.DataSource"/&gt;</P>
<P>
<P>重起tomcat。</P>
<P>连接方法：</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;Context initCtx = new InitialContext();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Context envCtx = (Context) initCtx.lookup("java:comp/env");<BR>&nbsp;&nbsp;&nbsp;&nbsp;DataSource ds = (DataSource) envCtx.lookup("jdbc/mydbcp");<BR>&nbsp;&nbsp;&nbsp;&nbsp;Connection conn = ds.getConnection();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Statement stmt = conn.createStatement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ResultSet rs = stmt.executeQuery("select * from systypes");<BR>三、测试</P>
<P>测试实例：test.jsp</P>
<P>&lt;%@ page language="java" pageEncoding="UTF-8"%&gt;<BR>&lt;%@ page contentType="text/html; charset=UTF-8"%&gt;<BR>&lt;%@ page import="java.sql.*,javax.sql.DataSource,javax.naming.*"%&gt;<BR>&lt;html&gt;<BR>&nbsp;&lt;head&gt;<BR>&nbsp;&nbsp;&lt;title&gt;<BR>&nbsp;&nbsp;&nbsp;tomcat 连接池<BR>&nbsp;&nbsp;&lt;/title&gt;<BR>&nbsp;&lt;/head&gt;<BR>&nbsp;&lt;body bgcolor="#ffffff"&gt;<BR>&nbsp;&nbsp;&lt;h3&gt;<BR>&nbsp;&nbsp;&nbsp;test<BR>&nbsp;&nbsp;&nbsp;&lt;br&gt;<BR>&nbsp;&nbsp;&nbsp;连接池3<BR>&nbsp;&nbsp;&lt;/h3&gt;<BR>&nbsp;&nbsp;&lt;%try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;Context initCtx = new InitialContext();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Context envCtx = (Context) initCtx.lookup("java:comp/env");<BR>&nbsp;&nbsp;&nbsp;&nbsp;DataSource ds = (DataSource) envCtx.lookup("jdbc/mydbcp");<BR>&nbsp;&nbsp;&nbsp;&nbsp;Connection conn = ds.getConnection();<BR>&nbsp;&nbsp;&nbsp;&nbsp;Statement stmt = conn.createStatement();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ResultSet rs = stmt.executeQuery("select * from systypes");<BR>&nbsp;&nbsp;&nbsp;&nbsp;while (rs.next()) {%&gt;</P>
<P>&nbsp;&nbsp;&lt;br&gt;<BR>&nbsp;&nbsp;&lt;%=rs.getString(1)%&gt;<BR>&nbsp;&nbsp;&lt;%}%&gt;<BR>&nbsp;&nbsp;&lt;%out.print("&lt;br&gt;Successful!成功！！\n");%&gt;<BR>&nbsp;&nbsp;&lt;%rs.close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;stmt.close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;conn.close();<BR>&nbsp;&nbsp;&nbsp;} catch (Exception e) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;out.print("出现例外！" + e.getMessage());<BR>&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<BR>&nbsp;&nbsp;&nbsp;}</P>
<P>&nbsp;&nbsp;%&gt;</P>
<P>&nbsp;&lt;/body&gt;<BR>&lt;/html&gt;</P>
<P>四、错误</P>
<P>错误1：Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'<BR>是没有将sql jdbc driver包放在common\lib\目录下。</P>
<P>错误2：Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.)<BR>SQL数据库补丁包的问题，如果访问的数据库是SP3，任何问题没有。不是SP3就会出现上面的错误。 </P>
<P>错误3：Name mydbcp is not bound in this Context<BR>在context.xml中加入<BR>&lt;ResourceLink<BR>&nbsp;&nbsp;&nbsp; global="jdbc/mydbcp"<BR>&nbsp;&nbsp;&nbsp; name="jdbc/mydbcp"<BR>type="javax.sql.DataSource"/&gt;</P><img src ="http://www.blogjava.net/dazern/aggbug/32727.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-02-27 20:44 <a href="http://www.blogjava.net/dazern/articles/32727.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat5.5.12 + mysql5.0 +Eclipse连接池配置</title><link>http://www.blogjava.net/dazern/articles/32721.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Mon, 27 Feb 2006 11:44:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/32721.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/32721.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/32721.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/32721.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/32721.html</trackback:ping><description><![CDATA[近日学习jsp时，为连接池的问题所困，经过一番努力，终于成功了，特此为大家献上。<BR><BR>1.Tomcat5.5.12中没有admin模块，需要读者自行下载<BR><BR>2.Tomcat中配置如下<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JNDI Name:&nbsp;&nbsp;&nbsp;&nbsp;jdbc/mysql<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Data Source URL:&nbsp;&nbsp;jdbc:mysql://202.118.133.88/xscj&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JDBC Driver Class:&nbsp;&nbsp; org.gjt.mm.mysql.Driver <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User Name:&nbsp;&nbsp;&nbsp;&nbsp;root<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Password:&nbsp;&nbsp;&nbsp;&nbsp; ********<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Max. Active Connections:&nbsp;&nbsp;&nbsp;&nbsp;4<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Max. Idle Connections:&nbsp;&nbsp;&nbsp;&nbsp;2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Max. Wait for Connection:&nbsp;&nbsp;&nbsp;&nbsp;500<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Validation Query:&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;注: <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.jdbc/mysql 前纲的jdbc也可以换成其它的, mysql为连池名，可任意起，在下文中注意使用<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.jdbc:mysql://192.168.0.16/xscj&nbsp;&nbsp; xscj为对应的数据库名<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;也可以换成jdbc:mysql://localhost/xscj&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.JDBC Driver Class : com.mysql.jdbc.Driver&nbsp;&nbsp; jdk中自带<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.User Name:为Mysql中数据库管理员名<BR><BR>3. 下面是最关键的一点&nbsp;&nbsp;<BR><BR>D:\Tomcat 5.5\conf\context.xml<BR><BR><PRE class=overflow>&lt;!-- The contents of this file will be loaded for each web application --&gt;<BR>&lt;Context&gt;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Default set of monitored resources --&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Uncomment this to disable session persistence across Tomcat restarts --&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Manager pathname="" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;--&gt;<BR> &lt;Resource<BR>&nbsp;&nbsp;&nbsp;&nbsp;name="mysql/xscj"<BR>&nbsp;&nbsp;&nbsp;&nbsp;type="javax.sql.DataSource"<BR>&nbsp;&nbsp;&nbsp;&nbsp;password="kingsoft88"<BR>&nbsp;&nbsp;&nbsp;&nbsp;driverClassName="com.mysql.jdbc.Driver"<BR>&nbsp;&nbsp;&nbsp;&nbsp;maxIdle="2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;maxWait="5000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;username="root"<BR>&nbsp;&nbsp;&nbsp;&nbsp;url="jdbc:mysql://202.118.133.88:3306/xscj"<BR>&nbsp;&nbsp;&nbsp;&nbsp;maxActive="4"/&gt;<BR><BR>&lt;/Context&gt;</PRE><BR>应相应的字段真加对了就可以了。<BR><BR>4.在Eclipse中编译时加入Tomcat 的DBCP和Pool包就不会有问题了.<BR>测试程序如下：<BR><PRE class=overflow>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;&lt;/title&gt;<BR>&lt;% <BR>&nbsp;&nbsp; out.print("开始测试:"+"&lt;br/&gt;");<BR>&nbsp;&nbsp; DataSource ds = null;<BR>&nbsp;&nbsp; Connection con=null;<BR>&nbsp;&nbsp; try{&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Context initCtx = new InitialContext(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Context ctx = (Context) initCtx.lookup("java:comp/env"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//这里的数据库前文提及的Data Source URL配置里包含的数据库。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ds = (DataSource)ctx.lookup("jdbc/xscj");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con=ds.getConnection();<BR>&nbsp;&nbsp; Statement stmt = con.createStatement();<BR>&nbsp;&nbsp; String strSql = "select * from xs";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //表中的字段读者自行添加<BR>&nbsp;&nbsp; ResultSet rs = stmt.executeQuery(strSql);<BR>&nbsp;&nbsp; while(rs.next()){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out.print(rs.getString(1)+"&lt;br/&gt;");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stmt.close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con.close();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>　　　 out.print("我的测试结束");<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; catch(Exception ex){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.print("出现例外，信息是:”+ ex.getMessage());<BR>&nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace();<BR>&nbsp;&nbsp; }<BR>%&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;</PRE><BR>总结：以上步骤均十分关键，如果有误对应错误如下<BR><BR>1、第一步错误，报错<BR>org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' <BR><BR>2、第三步错误，报错<BR>javax.naming.NameNotFoundException: Name jdbc is not bound in this Context <BR><BR>3、第四步错误，报错<BR>java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket<BR><BR>如果有上述错误，请检查对应步骤是否正确实施<img src ="http://www.blogjava.net/dazern/aggbug/32721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-02-27 19:44 <a href="http://www.blogjava.net/dazern/articles/32721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转载]Tomcat5.5.12配置详解</title><link>http://www.blogjava.net/dazern/articles/32719.html</link><dc:creator>夏天的零度</dc:creator><author>夏天的零度</author><pubDate>Mon, 27 Feb 2006 11:34:00 GMT</pubDate><guid>http://www.blogjava.net/dazern/articles/32719.html</guid><wfw:comment>http://www.blogjava.net/dazern/comments/32719.html</wfw:comment><comments>http://www.blogjava.net/dazern/articles/32719.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/dazern/comments/commentRss/32719.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/dazern/services/trackbacks/32719.html</trackback:ping><description><![CDATA[<P align=center><IMG style="WIDTH: 404px; HEIGHT: 94px" height=111 alt="" hspace=0 src="http://www.blueclassic.net/upload/sun.gif" width=490 align=baseline border=0></P>
<P align=left><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 今天下载了5.5.12版的TOMCAT,折腾了半天才知道TOMCAT5.0.28之后就没有了默认的admin模块,还以为我的配置哪出错了(花了半小时没找出原因:()。下面是网上当的一些关于TOMCAT配置方面的技巧，对相关的配置方法在没有改动原文的同时也做了适当修改，已红色字标记。目前使用的是最新的jdk为1.5+tomcat5.5.12这里只给出简单的配置。<BR>JDK1.5： <BR>JAVA_HOME=c:\j2sdk1.5 <BR>classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;（.;一定不能少，因为它代表当前路径) <BR>path=%JAVA_HOME%\bin<BR><BR>Tomcat 5.5.12:<BR>CATALINA_HOME：c:\tomcat<BR>CATALINA_BASE：c:\tomcat<BR>TOMCAT_HOME: C:\Tomcat <BR>修改classpath，classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet.jar; 启动tomcat，在IE中访问http://localhost:8080，如果看到tomcat的欢迎页面的话说明安装成功了。<BR><BR>下面可能会是经常出现和遇到的问题：<BR>1.下载http://www.eu.apache.org/dist/jakarta/tomcat-5/<BR>这里注意，在jakarta-tomcat-5.0.28.exe以前是有默认的admin模块，在jakarta-tomcat-5.5.9.exe则没有安装默认的admin模块，这时http://127.0.0.1:8080/admin打开时则会出现<BR>Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.<BR>因此我们现在需要下载"admin"package 包<BR>把jakarta-tomcat-5.5.x.zip 与 jakarta-tomcat-5.5.x-compat.zip 与 jakarta-tomcat-5.5.x-admin.zip三个文件解压在同一个目录中(如果使用jdk1.4，才需要compat.zip用jdk1.5就可以免了这个。) <FONT color=red>如果使用的是JDK1.5+tomcat5.5.12只需要将jakarta-tomcat-5.5.x-admin.zip文件解压到TOMCAT目录即可.</FONT><BR><BR>2.修改jakarta-tomcat-5.5.x\conf\tomcat-users.xml.<BR>添加管理员账号lizongbo，密码为lizongbopass<FONT color=red>.(一般在安装Tomcat的同时已提示输入用户名及密码,如果有设置此处可不做修改。)</FONT><BR>新xml如下：<USER username="lizongbo" password="lizongbopass" roles="admin,manager" /><BR></TOMCAT-USERS><BR>有时在%CATALINA_HOME%\server\webapps\admin\WEB-INF\web.xml里面也要做些修改<!-- Security is active on entire directory --><BR><SECURITY-CONSTRAINT><BR><DISPLAY-NAME>Tomcat Server Configuration Security Constraint<BR><WEB-RESOURCE-COLLECTION><BR><WEB-RESOURCE-NAME>Protected Area</WEB-RESOURCE-NAME><BR><!-- Define the context-relative URL(s) to be protected --><BR><URL-PATTERN>*.jsp</URL-PATTERN><BR><URL-PATTERN>*.do</URL-PATTERN><BR><URL-PATTERN>*.html</URL-PATTERN><BR></WEB-RESOURCE-COLLECTION><AUTH-CONSTRAINT><!-- Anyone with one of the listed roles may access this area --><BR><ROLE-NAME>admin</ROLE-NAME><BR></AUTH-CONSTRAINT><BR></SECURITY-CONSTRAINT><!-- Login configuration uses form-based authentication --><LOGIN-CONFIG><AUTH-METHOD>FORM</AUTH-METHOD><BR><REALM-NAME>Tomcat Server Configuration Form-Based Authentication Area</REALM-NAME><BR><FORM-LOGIN-CONFIG><FORM-LOGIN-PAGE>/login.jsp</FORM-LOGIN-PAGE> <FORM-ERROR-PAGE>/error.jsp</FORM-ERROR-PAGE> </FORM-LOGIN-CONFIG></LOGIN-CONFIG><BR><BR><!-- Security roles referenced by this web application --><SECURITY-ROLE><DESCRIPTION><BR>The role that is required to log in to the Administration Application<BR></DESCRIPTION><ROLE-NAME><BR>admin</ROLE-NAME><BR></SECURITY-ROLE><BR>无论是 Authetication (身份验证还是 Authorization ( 权限管控都只有设置相关的admin ROLE,当你想要新增或修改相关的AA, 就必须修改这一个文件,来符合你的环境.<BR><BR>3.修改jakarta-tomcat-5.5.x\conf\server.xml来解决编码问题。<BR>(给Connector 添加URIEncoding参数，参考http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)<BR>(可以设置成GB18030)<BR><CONNECTOR port="8080" <br />maxThreads="150" minSpareThreads="25" maxSpareThreads="75"<BR>enableLookups="false" redirectPort="8443" acceptCount="200"<BR>connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"<BR>compression="on" compressionMinSize="2048"<BR>noCompressionUserAgents="gozilla, traviata"<BR>compressableMimeType="text/html,text/xml"/&gt;<BR><BR><CONNECTOR port="8009" <br />enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="GBK"/&gt;<BR><FONT color=red>（这个还是比较头痛的问题，试了几种方法都不是太理想，有待继续解决，maxHttpHeaderSize="8192"）</FONT><BR><BR>4.启用支持gzip压缩.<BR>(http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&amp;i=81169)<BR>添加下列属性<BR>compression="on"<BR>compressionMinSize="2048"<BR>noCompressionUserAgents="gozilla, traviata"<BR>compressableMimeType="text/html,text/xml"<BR><BR>5.设置虚拟主机。<BR>在jakarta-tomcat-5.5.x\下建立文件夹vhost\www.mydomain.com。<BR>然后修改jakarta-tomcat-5.5.x\conf\server.xml<BR><ENGINE defaultHost="localhost" name="Catalina"><HOST name="http://www.mydomain.com/" appBase="vhost/www.mydomain.com"></HOST><HOST name="localhost" appBase="webapps"></HOST><REALM className="org.apache.catalina.realm.UserDatabaseRealm" /></ENGINE><BR>6.添加数据库驱动,更新mail.jar和actiovation.jar<BR>复制mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar到 jakarta-tomcat-5.5.x\common\lib\<BR>还有javamail 1.3.2的mail.jar，jaf-1_0_2的 activation.jar<BR>msSQl 2000 JDBC sp3，msbase.jar,msutil,jar,mssqlserver.jar<BR><BR>7.配置SSL<BR>参考 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html<BR>D:\j2sdk1.4.2_06\bin&gt;%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA<BR>输入keystore密码： lizongbossl<BR>您的名字与姓氏是什么？<BR>[tomcat5.5.x]： tomcat5.5.x<BR>您的组织单位名称是什么？<BR>[jakarta]： jakarta<BR>您的组织名称是什么？<BR>[apache]： apache<BR>您所在的城市或区域名称是什么？<BR>[hzcity]： hzcity<BR>您所在的州或省份名称是什么？<BR>[gdp]： gdp<BR>该单位的两字母国家代码是什么<BR>[CN]： CN<BR>CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN 正确吗？<BR>[否]： y<BR><BR>输入<TOMCAT>的主密码<BR>（如果和 keystore 密码相同，按回车）：<BR><BR>(必须密码一致，因此直接回车)<BR>然后再把userhome(例如：C:\Documents and Settings\lizongbo\)下的.keystore复制到<BR>tomcat的conf\目录下。<BR>(例如：D:\jakarta-tomcat-5.5.x\conf\.keystore<BR>配置jakarta-tomcat-5.5.x\conf\server.xml<BR>加上<BR><CONNECTOR port="8443" <br />maxThreads="150" minSpareThreads="25" maxSpareThreads="75"<BR>enableLookups="false" disableUploadTimeout="true"<BR>acceptCount="100" scheme="https" secure="true"<BR>clientAuth="false" sslProtocol="TLS"<BR>keystoreFile="conf/.keystore"<BR>keystorePass="lizongbossl"&gt; <!--与先前设置的密码一致--><BR></CONNECTOR><BR>8.禁止文件目录列表，<BR>修改jakarta-tomcat-5.5.x\conf\web.xml，把listing设置为false<BR><SERVLET><BR><SERVLET-NAME>default</SERVLET-NAME><BR><SERVLET-CLASS>org.apache.catalina.servlets.DefaultServlet</SERVLET-CLASS><BR><INIT-PARAM><PARAM-NAME>debug</PARAM-NAME> <PARAM-VALUE>0</PARAM-VALUE> </INIT-PARAM><BR><INIT-PARAM><PARAM-NAME>listings</PARAM-NAME> <PARAM-VALUE>true</PARAM-VALUE> </INIT-PARAM><BR><LOAD-ON-STARTUP>1</LOAD-ON-STARTUP><BR></SERVLET><BR>9.指定了自己的javaEncoding<BR>(参考 http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html <BR><SERVLET><BR><SERVLET-NAME>jsp</SERVLET-NAME><BR><SERVLET-CLASS>org.apache.jasper.servlet.JspServlet</SERVLET-CLASS><BR><INIT-PARAM><BR><PARAM-NAME>fork</PARAM-NAME> <PARAM-VALUE>false</PARAM-VALUE> </INIT-PARAM><BR><INIT-PARAM><BR><PARAM-NAME>javaEncoding</PARAM-NAME> <PARAM-VALUE>GB18030</PARAM-VALUE> </INIT-PARAM><BR><INIT-PARAM><BR><PARAM-NAME>xpoweredBy</PARAM-NAME> <PARAM-VALUE>true</PARAM-VALUE> </INIT-PARAM><BR><LOAD-ON-STARTUP>3</LOAD-ON-STARTUP><BR></SERVLET><BR>10.添加rar,iso等的mime-type映射<BR>避免在浏览器里直接打开。<BR><MIME-MAPPING><BR><EXTENSION>mht</EXTENSION><BR><MIME-TYPE>text/x-mht</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>rar</EXTENSION><BR><MIME-TYPE>application/octet-stream</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>iso</EXTENSION><BR><MIME-TYPE>application/octet-stream</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>ape</EXTENSION><BR><MIME-TYPE>application/octet-stream</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>rmvb</EXTENSION><BR><MIME-TYPE>application/octet-stream</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>ico</EXTENSION><BR><MIME-TYPE>image/x-icon</MIME-TYPE><BR></MIME-MAPPING><BR>10.1对html静态页面设置编码<BR><!--  修改下面两行以支持静态超文本的自动编码<br/>  --><MIME-MAPPING><BR><EXTENSION>htm</EXTENSION><BR><MIME-TYPE>text/html;charset=gb2312</MIME-TYPE><BR></MIME-MAPPING><MIME-MAPPING><BR><EXTENSION>html</EXTENSION><BR><MIME-TYPE>text/html;charset=gb2312</MIME-TYPE><BR></MIME-MAPPING></WEB-APP><BR>11.添加welcome-file-list，并调整顺序。<BR><WELCOME-FILE-LIST><BR><WELCOME-FILE>index.jsp</WELCOME-FILE><BR><WELCOME-FILE>index.html</WELCOME-FILE><BR><WELCOME-FILE>index.htm</WELCOME-FILE><BR><WELCOME-FILE>default.html</WELCOME-FILE><BR><WELCOME-FILE>default.htm</WELCOME-FILE><BR><WELCOME-FILE>default.jsp</WELCOME-FILE><BR></P><img src ="http://www.blogjava.net/dazern/aggbug/32719.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/dazern/" target="_blank">夏天的零度</a> 2006-02-27 19:34 <a href="http://www.blogjava.net/dazern/articles/32719.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>