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

<channel>
	<title>CNlaoKe&#039;s Blog &#187; Java</title>
	<atom:link href="http://blog.cnlaoKe.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cnlaoKe.com</link>
	<description>Rome was not built in a day!</description>
	<lastBuildDate>Wed, 25 Aug 2010 09:45:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>tomcat 添加虚拟目录</title>
		<link>http://blog.cnlaoKe.com/2009/05/04/92/</link>
		<comments>http://blog.cnlaoKe.com/2009/05/04/92/#comments</comments>
		<pubDate>Mon, 04 May 2009 09:58:06 +0000</pubDate>
		<dc:creator>CNlaoKe</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.cnlaoKe.com/2009/05/04/92/</guid>
		<description><![CDATA[在TOMCAT安装目录下conf\
建立目录Catalina
再在Catalina 里建立localhost目录
(我的路径 E:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost)
然后在localhost目录里新建XML文件
我这里新建的是jsp.xml
内容如下

&#60;Context path=&#8221;/jsp&#8221; docBase=&#8221;D:\Projects\jsp&#8221; debug=&#8221;0&#8243; privileged=&#8221;true&#8221;&#62;
&#60;/Context&#62;
path 是指用tomcat访问的路径
如http://localhost:8080/jsp
docbase是指代码程序存在的地址
D:\Projects\jsp
如果D盘没有projects目录，记得新建projects 然后再projects目录建立jsp目录
把hello.jsp放到目录里
hello.jsp代码如下

&#60;HTML&#62;
&#60;HEAD&#62;
&#60;TITLE&#62;hello jsp&#60;/TITLE&#62;
&#60;!&#8211; the variable, message, is declared and initialized &#8211;&#62;
&#60;%!
String message = &#8220;Hello, World, from JSP&#8221;;
%&#62;
&#60;/HEAD&#62;
&#60;BODY&#62;
&#60;!&#8211; the value of the variable, message, is inserted between h2 tags &#8211;&#62;
&#60;h2&#62;&#60;font color=&#8221;#AA0000&#8243;&#62;&#60;%= message%&#62;&#60;/font&#62;&#60;/h2&#62;
&#60;h3&#62;&#60;font color=&#8221;#AA0000&#8243;&#62;
&#60;!&#8211; the java.util.Date method is executed and the result inserted between h3 tags [...]]]></description>
		<wfw:commentRss>http://blog.cnlaoKe.com/2009/05/04/92/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jdk6.0和tomcat6.0经典配置</title>
		<link>http://blog.cnlaoKe.com/2009/05/02/90/</link>
		<comments>http://blog.cnlaoKe.com/2009/05/02/90/#comments</comments>
		<pubDate>Sat, 02 May 2009 09:56:31 +0000</pubDate>
		<dc:creator>CNlaoKe</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.cnlaoKe.com/2009/05/02/90/</guid>
		<description><![CDATA[



准备：
安装和配置jdk6.0和tomcat6.0
调试(jsp):
1.到Tomcat的安装目录的webapps目录，可以看到ROOT，examples, tomcat-docs之类Tomcat自带的的目录.
2.在webapps目录下新建一个目录，起名叫myapp.
3.myapp下新建一个目录WEB-INF，注意，目录名称是区分大小写的.
4.WEB-INF下新建一个文件web.xml，内容如下：
&#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;gb2312&#8243;?&#62;
&#60;web-app&#62;
&#60;display-name&#62;My Web Application&#60;/display-name&#62;
&#60;description&#62;
A application for test.
&#60;/description&#62;
&#60;/web-app&#62;
5.在myapp下新建一个测试的jsp页面，文件名为index.jsp，文件内容如下：
&#60;html&#62;
&#60;body&#62;
&#60;center&#62;Now time is: &#60;%=new java.util.Date()%&#62;&#60;/center&#62;
&#60;/body&#62;
&#60;/html&#62;
6.重启Tomcat.
7.打开浏览器，输入http://localhost:8080/myapp/index.jsp 看到当前时间的话说明就成功了.
调试(servlet):
1.用你最熟悉的编辑器（建议使用有语法检查的java ide）新建一个servlet程序，文件名为TestServlet.java，文件内容如下:package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet &#8230;{
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException &#8230;{
PrintWriter out=response.getWriter();
out.println(&#8221;&#60;html&#62;&#60;body&#62;&#60;h1&#62;This is a servlet test.&#60;/h1&#62;&#60;/body&#62;&#60;/html&#62;&#8221;);
out.flush();
}
}
2.编译
将TestServlet.java放在c:\test下，使用如下命令编译:
C:\Test&#62;javac TestServlet.java
然后在c:\Test下会产生一个编译后的servlet文件：TestServlet.class
(如果编译时出现无法import javax.servlet.*。那么就是应该把\Tomcat\lib里面的servlet-api.jar文件拷贝到D:\Java \jdk1.6.0\lib中，并在classpath中添加环境变量%JAVA_HOME%\lib\servlet-api.jar再次编译，就没有 问题了)
[Huoho.Com编辑]
3.将结构test\TestServlet.class剪切到D:\Tomcat6.0\webapps\myapp\WEB-INF\classes 下，也就是剪切那个test目录到classes目录下。如果classes目录不存在，就新建一个。现在webapps\myapp\WEB-INF \classes下有test\Test.class的文件目录结构.
4.（web.xml文件进行注册）修改webapps\myapp\WEB-INF\web.xml，添加servlet和servlet-mapping.编辑后的web.xml如下所示，红色为添加的内容:
&#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;gb2312&#8243;?&#62;
&#60;web-app&#62;
&#60;display-name&#62;My Web Application&#60;/display-name&#62;
&#60;description&#62;
A application for test.
&#60;/description&#62;
&#60;servlet&#62;
&#60;servlet-name&#62;Test&#60;/servlet-name&#62;
&#60;servlet-class&#62;test.TestServlet&#60;/servlet-class&#62;
&#60;/servlet&#62;
&#60;servlet-mapping&#62;
&#60;servlet-name&#62;Test&#60;/servlet-name&#62;
&#60;url-pattern&#62;/Test&#60;/url-pattern&#62;
&#60;/servlet-mapping&#62;
&#60;/web-app&#62;   这段话中的servlet这一段声明了你要调用的Servlet，而servlet-mapping则是将声明的servlet&#8221;映射&#8221;到地址/Test上.
5.好了，重启动Tomcat，启动浏览器，输入http://localhost:8080/myapp/Test [...]]]></description>
		<wfw:commentRss>http://blog.cnlaoKe.com/2009/05/02/90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
