﻿<?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-Nonels’Blog-随笔分类-J2EE</title><link>http://www.blogjava.net/nonels/category/34365.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 20 Oct 2008 18:15:47 GMT</lastBuildDate><pubDate>Mon, 20 Oct 2008 18:15:47 GMT</pubDate><ttl>60</ttl><item><title>JPBC ing： 留言板之三：留言板JSP代码</title><link>http://www.blogjava.net/nonels/archive/2008/10/16/234785.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Thu, 16 Oct 2008 15:54:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/10/16/234785.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/234785.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/10/16/234785.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/234785.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/234785.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &lt;!				DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"				&gt;																														&lt;%																								@ page language						=						"			...&nbsp;&nbsp;<a href='http://www.blogjava.net/nonels/archive/2008/10/16/234785.html'>阅读全文</a><img src ="http://www.blogjava.net/nonels/aggbug/234785.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-10-16 23:54 <a href="http://www.blogjava.net/nonels/archive/2008/10/16/234785.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JPBC ing： 留言板之二：处理jsp中出现的中文乱码问题--字符过滤器</title><link>http://www.blogjava.net/nonels/archive/2008/10/16/234784.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Thu, 16 Oct 2008 15:51:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/10/16/234784.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/234784.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/10/16/234784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/234784.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/234784.html</trackback:ping><description><![CDATA[      在参数传递过程中，经常会碰到中文乱码问题，有好多种解决方法，其中一种就是用到过滤器。<br /><br />CharacterEncodingFilter.java<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> filter;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> java.io.IOException;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.Filter;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.FilterChain;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.FilterConfig;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.ServletException;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.ServletRequest;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> javax.servlet.ServletResponse;<br /><img id="Codehighlighter1_258_306_Open_Image" onclick="this.style.display='none'; Codehighlighter1_258_306_Open_Text.style.display='none'; Codehighlighter1_258_306_Closed_Image.style.display='inline'; Codehighlighter1_258_306_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_258_306_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_258_306_Closed_Text.style.display='none'; Codehighlighter1_258_306_Open_Image.style.display='inline'; Codehighlighter1_258_306_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_258_306_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span><span id="Codehighlighter1_258_306_Open_Text"><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * jsp中文乱码的Filter过滤器<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> nonels<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /> *<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> </span><span style="COLOR: #008000">*/</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_364_1154_Open_Image" onclick="this.style.display='none'; Codehighlighter1_364_1154_Open_Text.style.display='none'; Codehighlighter1_364_1154_Closed_Image.style.display='inline'; Codehighlighter1_364_1154_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_364_1154_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_364_1154_Closed_Text.style.display='none'; Codehighlighter1_364_1154_Open_Image.style.display='inline'; Codehighlighter1_364_1154_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> CharacterEncodingFilter </span><span style="COLOR: #0000ff">implements</span><span style="COLOR: #000000"> Filter </span><span id="Codehighlighter1_364_1154_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_364_1154_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000"> String encoding;    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    字符编码</span><span style="COLOR: #008000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">protected</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">boolean</span><span style="COLOR: #000000"> ignore;    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    是否忽略大小写</span><span style="COLOR: #008000"><br /><img id="Codehighlighter1_509_800_Open_Image" onclick="this.style.display='none'; Codehighlighter1_509_800_Open_Text.style.display='none'; Codehighlighter1_509_800_Closed_Image.style.display='inline'; Codehighlighter1_509_800_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_509_800_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_509_800_Closed_Text.style.display='none'; Codehighlighter1_509_800_Open_Image.style.display='inline'; Codehighlighter1_509_800_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> init(FilterConfig filterConfig) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> ServletException </span><span id="Codehighlighter1_509_800_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_509_800_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> filterConfig.getInitParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">encoding</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        String value </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> filterConfig.getInitParameter(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ignore</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img id="Codehighlighter1_646_668_Open_Image" onclick="this.style.display='none'; Codehighlighter1_646_668_Open_Text.style.display='none'; Codehighlighter1_646_668_Closed_Image.style.display='inline'; Codehighlighter1_646_668_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_646_668_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_646_668_Closed_Text.style.display='none'; Codehighlighter1_646_668_Open_Image.style.display='inline'; Codehighlighter1_646_668_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (value </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_646_668_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_646_668_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            ignore </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /><img id="Codehighlighter1_711_733_Open_Image" onclick="this.style.display='none'; Codehighlighter1_711_733_Open_Text.style.display='none'; Codehighlighter1_711_733_Closed_Image.style.display='inline'; Codehighlighter1_711_733_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_711_733_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_711_733_Closed_Text.style.display='none'; Codehighlighter1_711_733_Open_Image.style.display='inline'; Codehighlighter1_711_733_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (value.equalsIgnoreCase(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">true</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)) </span><span id="Codehighlighter1_711_733_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_711_733_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            ignore </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /><img id="Codehighlighter1_775_797_Open_Image" onclick="this.style.display='none'; Codehighlighter1_775_797_Open_Text.style.display='none'; Codehighlighter1_775_797_Closed_Image.style.display='inline'; Codehighlighter1_775_797_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_775_797_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_775_797_Closed_Text.style.display='none'; Codehighlighter1_775_797_Open_Image.style.display='inline'; Codehighlighter1_775_797_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (value.equalsIgnoreCase(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">yes</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)) </span><span id="Codehighlighter1_775_797_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_775_797_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            ignore </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> doFilter(ServletRequest request, ServletResponse response,<br /><img id="Codehighlighter1_940_1101_Open_Image" onclick="this.style.display='none'; Codehighlighter1_940_1101_Open_Text.style.display='none'; Codehighlighter1_940_1101_Closed_Image.style.display='inline'; Codehighlighter1_940_1101_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_940_1101_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_940_1101_Closed_Text.style.display='none'; Codehighlighter1_940_1101_Open_Image.style.display='inline'; Codehighlighter1_940_1101_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            FilterChain filterChain) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> IOException, ServletException </span><span id="Codehighlighter1_940_1101_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_940_1101_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_1005_1098_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1005_1098_Open_Text.style.display='none'; Codehighlighter1_1005_1098_Closed_Image.style.display='inline'; Codehighlighter1_1005_1098_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1005_1098_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1005_1098_Closed_Text.style.display='none'; Codehighlighter1_1005_1098_Open_Image.style.display='inline'; Codehighlighter1_1005_1098_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (ignore </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> encoding !</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_1005_1098_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_1005_1098_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />             request.setCharacterEncoding(encoding);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />             filterChain.doFilter(request, response);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img id="Codehighlighter1_1127_1149_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1127_1149_Open_Text.style.display='none'; Codehighlighter1_1127_1149_Closed_Image.style.display='inline'; Codehighlighter1_1127_1149_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1127_1149_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1127_1149_Closed_Text.style.display='none'; Codehighlighter1_1127_1149_Open_Image.style.display='inline'; Codehighlighter1_1127_1149_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> destroy() </span><span id="Codehighlighter1_1127_1149_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.blogjava.net/images/dot.gif" /></span><span id="Codehighlighter1_1127_1149_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        encoding </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span></div><br />XML中的配置加上以下：<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />      <span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filter</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filter-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">CharacterEncodingFilter</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filter-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filter-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">filter.CharacterEncodingFilter</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filter-class</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">ignore</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">true</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">encoding</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">GBK</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">param-value</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">init-param</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filter</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filter-mapping</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">filter-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">CharacterEncodingFilter</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filter-name</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000">/*</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">url-pattern</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">filter-mapping</span><span style="COLOR: #0000ff">&gt;</span></div><img src ="http://www.blogjava.net/nonels/aggbug/234784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-10-16 23:51 <a href="http://www.blogjava.net/nonels/archive/2008/10/16/234784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JPBC ing： 留言板之一：用JAVABEAN与DAO封装数据的业务逻辑及操作</title><link>http://www.blogjava.net/nonels/archive/2008/10/16/234782.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Thu, 16 Oct 2008 15:45:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/10/16/234782.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/234782.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/10/16/234782.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/234782.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/234782.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 首先，先用DAO把数据业务逻辑部分分离开来，因为我只用到MySQL，所以就省略了工厂类，定了一个业务逻辑的接口及实现它的类。     MessageDAO.java       package DAO.iface;import java.util.List;/** *//** * 进行数据操作的业务逻辑类接口的DAO * @author Administrator * */public int...&nbsp;&nbsp;<a href='http://www.blogjava.net/nonels/archive/2008/10/16/234782.html'>阅读全文</a><img src ="http://www.blogjava.net/nonels/aggbug/234782.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-10-16 23:45 <a href="http://www.blogjava.net/nonels/archive/2008/10/16/234782.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用SAX解析XML文档</title><link>http://www.blogjava.net/nonels/archive/2008/09/28/231622.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Sun, 28 Sep 2008 03:09:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/09/28/231622.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/231622.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/09/28/231622.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/231622.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/231622.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 步骤1.一个简单的XML文档：   XML代码：&lt;?xml version="1.0" encoding="GBK"?&gt;  &lt;StudentInfo&gt;      &lt;student&gt;          &lt;name&gt;赵海波&lt;/name&gt;          &lt;sex&gt;男&lt;/sex&gt;          &lt;lesson...&nbsp;&nbsp;<a href='http://www.blogjava.net/nonels/archive/2008/09/28/231622.html'>阅读全文</a><img src ="http://www.blogjava.net/nonels/aggbug/231622.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-09-28 11:09 <a href="http://www.blogjava.net/nonels/archive/2008/09/28/231622.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用DOM解析XML文档</title><link>http://www.blogjava.net/nonels/archive/2008/09/28/231617.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Sun, 28 Sep 2008 03:03:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/09/28/231617.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/231617.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/09/28/231617.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/231617.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/231617.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要:         当使用DOM解析XML文档时，使用的是DOM的思想，因而不可避免需要将XML文档转换成DOM树。DOM解析器在装入XML文档时，已经在内存中将XML文档的每个元素转换成DOM树的每个节点了。<br><br>对于下面的一个简单XML文档：<br><br>   xml代码：<br>&nbsp;&nbsp;<a href='http://www.blogjava.net/nonels/archive/2008/09/28/231617.html'>阅读全文</a><img src ="http://www.blogjava.net/nonels/aggbug/231617.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-09-28 11:03 <a href="http://www.blogjava.net/nonels/archive/2008/09/28/231617.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat6.0 配置</title><link>http://www.blogjava.net/nonels/archive/2008/09/04/226984.html</link><dc:creator>nonels</dc:creator><author>nonels</author><pubDate>Thu, 04 Sep 2008 07:43:00 GMT</pubDate><guid>http://www.blogjava.net/nonels/archive/2008/09/04/226984.html</guid><wfw:comment>http://www.blogjava.net/nonels/comments/226984.html</wfw:comment><comments>http://www.blogjava.net/nonels/archive/2008/09/04/226984.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/nonels/comments/commentRss/226984.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/nonels/services/trackbacks/226984.html</trackback:ping><description><![CDATA[    <span style="font-size: 10.5pt; font-family: 宋体;">在成功安装JDK的前提下，安装tomcat6.0（假设安装路径为C：，一般选择FULL安装，4.0以上版本不用配置环境变量）系统变量中添加以下环境变量</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">(</span><span style="font-size: 10.5pt; font-family: 宋体;">假定你的</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">j2sdk</span><span style="font-size: 10.5pt; font-family: 宋体;">安装在</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">c:"jdk1.6</span><span style="font-size: 10.5pt; font-family: 宋体;">）：</span> <span style="font-size: 10.5pt; font-family: 'Times New Roman';"><font color="#ff0000">JAVA_HOME</font>=</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">c:"jdk1.6。</span><font size="3"><span style="font-size: 10.5pt; font-family: 宋体;">接着可以启动</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">tomcat</span><span style="font-size: 10.5pt; font-family: 宋体;">，在</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">IE</span><span style="font-size: 10.5pt; font-family: 宋体;">中访问</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';"><a href="http://localhost:8080/"><span style="color: blue;">http://localhost:8080</span></a></span><span style="font-size: 10.5pt; font-family: 宋体;">，如果看到</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">tomcat</span><span style="font-size: 10.5pt; font-family: 宋体;">的欢迎页面的话说明安装成功了</span></font>。<br />
    然后对tomcat进行配置：<br />
    <font size="3"><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;">第一步</span>：建立自己的</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">jsp app</span><span style="font-size: 10.5pt; font-family: 宋体;">目录</span></font>：<br /><span style="font-size: 10.5pt; font-family: 'Times New Roman';">        </span><font size="3"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">1.</span><span style="font-size: 10.5pt; font-family: 宋体;">在</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">webapps</span><span style="font-size: 10.5pt; font-family: 宋体;">目录下新建一个目录，起名叫</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">myapp</span><span style="font-size: 10.5pt; font-family: 宋体;">；</span> <span style="font-size: 10pt; font-family: 'Times New Roman';"><br /></span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">        2.myapp</span><span style="font-size: 10.5pt; font-family: 宋体;">下新建一个目录</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">WEB-INF</span><span style="font-size: 10.5pt; font-family: 宋体;">，注意，目录名称是区分大小写的；</span> <span style="font-size: 10pt; font-family: 'Times New Roman';"><br /></span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">        3.WEB-INF</span><span style="font-size: 10.5pt; font-family: 宋体;">下新建一个文件</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">web.xml</span><span style="font-size: 10.5pt; font-family: 宋体;">，内容如下：</span></font>  <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%;"><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml version="1.0" encoding="ISO-8859-1"</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);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 255);">&lt;!</span><span style="color: rgb(255, 0, 255);">DOCTYPE web-app<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(255, 0, 255);">PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(255, 0, 255);">"http://java.sun.com/dtd/web-app_2_3.dtd"</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);"> 6</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">web-app</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);"> 8</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">display-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">My Web Application</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">display-name</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);"> 9</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 /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">A application for test.<br /></span><span style="color: rgb(0, 128, 128);">11</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 /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">web-app</span><span style="color: rgb(0, 0, 255);">&gt;</span></div>
   <br />
    <font size="3">4<span style="font-size: 10.5pt; font-family: 'Times New Roman';">.</span><span style="font-size: 10.5pt; font-family: 宋体;">在</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">myapp</span><span style="font-size: 10.5pt; font-family: 宋体;">下新建一个测试的</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">jsp</span><span style="font-size: 10.5pt; font-family: 宋体;">页面，文件名为</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">index.jsp</span><span style="font-size: 10.5pt; font-family: 宋体;">，文件内容如下<br />
  </span></font><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%;"><span style="color: rgb(0, 128, 128);">1</span> <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);">2</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);">3</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">center</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);">4</span> <span style="color: rgb(0, 0, 0);">Now time is: </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">%=new </span><span style="color: rgb(255, 0, 0);">java.util.Date()%</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);">5</span> <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">center</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);">6</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);">7</span> <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></div><font size="3"><span style="font-size: 10.5pt; font-family: 宋体;">    <font size="2">5</font></span></font><font size="2"><span style="font-size: 10.5pt; font-family: 'Times New Roman';">.</span><span style="font-size: 10.5pt; font-family: 宋体;">重启</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">Tomcat </span><span style="font-size: 10pt; font-family: 'Times New Roman';"><br /></span><span style="font-size: 10.5pt; font-family: 'Times New Roman';">        6.</span><span style="font-size: 10.5pt; font-family: 宋体;">打开浏览器，输入</span></font><a href="http://localhost:8080/myapp/index.jsp" target="_blank">http://localhost:8080/myapp/index.jsp</a><font size="2"><span style="font-size: 10.5pt; font-family: 宋体;">看到当前时间的话说明就成功了<br /><br />
    </span></font><font size="2"><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;">第二步</span>：建立自己的Servlet：<br />
    写入你的第一个Servlet:<br />
    在你新建的Application <font color="#ff0000">myapp/WEB-INF/classes</font><span style="color: rgb(0, 1, 255);">/test</span>目录下新建HelloWorld.java<br />
    </span></font><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%;"><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test;<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 4</span>  <span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> javax.servlet.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 5</span>  <span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> javax.servlet.http.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 6</span>  <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> HelloWorld </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> HttpServlet<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">   {<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    response.setContentType(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">text/html</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    PrintWriter out </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> response.getWriter();<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;html&gt;&lt;head&gt;&lt;title&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">    out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">This is my first Servlet</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;/title&gt;&lt;/head&gt;&lt;body&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">    out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;h1&gt;Hello,World!&lt;/h1&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">    out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;/body&gt;&lt;/html&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">   <br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">   }<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">   }</span></div><font size="2"><span style="font-size: 10.5pt; font-family: 宋体;">    </span></font><font size="2">把Tomcat中lib里面的</font><font color="#ff0000" size="2">servlet-api.jar</font><font size="2">文件拷贝到C:"JDK"jre"lib"ext中</font>，编译<font size="2"><span style="font-size: 10.5pt; font-family: 宋体;">HelloWorld.java<br />
    </span></font><font size="2">Servlet必须使用C:"Tomcat"webapps"myapp"WEB-INF这个目录下面的web.xml文件进行注册，用EditPlus打开这个web.xml文件，在&lt;web-app&gt;&lt;/web-app&gt;添加下面这段程序:</font><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%;"><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> test;<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> TestBean<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> String name </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> TestBean(String nameInit){<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.name </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> nameInit;<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setName(String newName){<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">newName;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> String getName(){<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span> <span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.name;<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">}</span></div><font size="2"><span style="font-size: 10.5pt; font-family: 宋体;">       </span></font><font size="2">然后照样用<font color="#ff9900">javac TestBean.java</font>来编译这个文件。<br /><br />
      </font><font size="2">2.然后在你新建的应用程序目录<font color="#ff0000">myapp</font><font color="#000000">下新建一个新的jsp文件：testBean.jsp<br />
       </font></font><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%;"><span style="color: rgb(0, 128, 128);"> 1</span> <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);">@ page 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);">test.TestBean</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);"> 2</span> <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);"> 3</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);"> 4</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);">Test Bean</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);"> 5</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);"> 6</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);"> 7</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">center</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);"> 8</span> <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);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">   TestBean testBean </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, 255);">new</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);"> TestBean(</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://czl.cn</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);">);<br /></span><span style="color: rgb(0, 128, 128);">10</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);">11</span> <span style="color: rgb(0, 0, 0);">Java Bean Test:<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    The author's blog address is</span><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);">=</span><span style="background-color: rgb(245, 245, 245); color: rgb(0, 0, 0);">testBean.getName()</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);">13</span> <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">center</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> <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);">15</span> <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><font size="2"><font color="#000000">      </font></font><font size="2">确定各个文件的位置，如下<br />
      </font><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%;"><span style="color: rgb(0, 0, 0);">myapp"index.jsp<br /></span><span style="color: rgb(0, 0, 0);">myapp"testBean.jsp<br /></span><span style="color: rgb(0, 0, 0);">myapp"WEB-INF"web.xml<br /></span><span style="color: rgb(0, 0, 0);">myapp"WEB-INF"classes"test"HelloWorld.class<br /></span><span style="color: rgb(0, 0, 0);">myapp"WEB-INF"classes"test"TestBean.class</span></div><font size="2">       </font><p><font size="2">     3.重启Tomcat如果需要的话，在浏览器输入:<span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;"><a href="http://localhost:8080/myapp/testBean.jsp" target="_blank">http://localhost:8080/myapp/testBean.jsp</a> </span><font face="Courier New">幸运的话就会看到:</font></span></font></p><p><font size="2"><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;"><font color="#ff9900">     Java Bean Test: The author's blog address isHttp://czl.cn</font></span></span></font></p>
    
<span style="font-size: 10.5pt; font-family: 宋体;"><font size="2">这样就完成了整个Tomcat下的jsp、servlet和javabean的配置。<br /><br />
    </font></span><br /><p><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;"><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-weight: bold;">   第四步：</span></span></span><span style="font-size: 10.5pt; font-family: 宋体;">配置虚拟目录</span></span></p><p><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-size: 10.5pt; font-family: 宋体;">      打开 Tomcat6.0"conf"server.xml 文件，在 &lt;Host&gt; 和 &lt;/Host&gt; 之间加入     </span></span><br /></p><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%;"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Context </span><span style="color: rgb(255, 0, 0);">path</span><span style="color: rgb(0, 0, 255);">="/myapp"</span><span style="color: rgb(255, 0, 0);"> docBase</span><span style="color: rgb(0, 0, 255);">="D:"myapp"</span><span style="color: rgb(255, 0, 0);"> debug</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(255, 0, 0);"> reloadable</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(255, 0, 0);"> crossContext</span><span style="color: rgb(0, 0, 255);">="true"</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></div><img src ="http://www.blogjava.net/nonels/aggbug/226984.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/nonels/" target="_blank">nonels</a> 2008-09-04 15:43 <a href="http://www.blogjava.net/nonels/archive/2008/09/04/226984.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>