Chinaunix首页 | 论坛 | 博客
  • 博客访问: 526128
  • 博文数量: 135
  • 博客积分: 3568
  • 博客等级: 中校
  • 技术积分: 1942
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-19 17:52
文章分类

全部博文(135)

文章存档

2012年(29)

2011年(41)

2010年(26)

2009年(12)

2008年(9)

2007年(12)

2006年(6)

分类: Java

2011-06-15 22:47:42

参考:
   

测试步骤:
1. 修改 C:\WINDOWS\system32\drivers\etc\hosts ,追加以下两行:
  1. 127.0.0.1 mp3.com
  2. 127.0.0.1 mp4.com
2. 修改 ${CATALINA_HOME}/conf/server.xml 追加以下两个 virtual host
  1. <?xml version='1.0' encoding='utf-8'?>
  2. <Server port="8005" shutdown="SHUTDOWN">
  3.   ...
  4.   <Service name="Catalina">
  5.     ...
  6.     <Engine name="Catalina" defaultHost="localhost">
  7.       ...
  8.       <Host name="mp3.com" appBase="webapps-mp3"
  9.             unpackWARs="true" autoDeploy="true"
  10.             xmlValidation="false" xmlNamespaceAware="false" />
  11.       <Host name="mp4.com" appBase="webapps-mp4"
  12.             unpackWARs="true" autoDeploy="true"
  13.             xmlValidation="false" xmlNamespaceAware="false" />
  14.       ...
  15.     </Engine>
  16.   </Service>
  17. </Server>
3. 创建目录${CATALINA_HOME}/webapps-mp3
   创建${CATALINA_HOME}/webapps-mp3/ROOT/index.jsp
  1. <%@ page contentType="text/html; charset=GBK"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  6. <title>test tomcat cluster : Page B</title>
  7. </head>
  8. <body>
  9. <div>this is a test page</div>
  10. <div>cur path = [<%=request.getRealPath(".") %>]</div>
  11. </body>
  12. </html>
   创建${CATALINA_HOME}/webapps-mp3/ROOT/WEB-INF/web.xml
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <web-app xmlns=""
  3.    xmlns:xsi=""
  4.    xsi:schemaLocation=" /web-app_2_5.xsd"
  5.    version="2.5">

  6.     <welcome-file-list>
  7.         <welcome-file>index.jsp</welcome-file>
  8.     </welcome-file-list>
  9. </web-app>
4. 启动tomcat
5. 访问 输出以下信息:
  1. this is a test page
  2. cur path = [E:\apache-tomcat-6.0.29-VH\webapps-mp3\ROOT\.]
   访问 输出以下信息:
  1. this is a test page
  2. cur path = [E:\apache-tomcat-6.0.29-VH\webapps-mp4\ROOT\.]


Over~~~~, 通过不同的域名,访问不同的目录。


阅读(1085) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~