你将默认的Context的docbase指向E:\JIA 不就行了吗?具体就是修改server.xml中的context结点。至于你说“server.xml-------------手动加过context标签,没用”怎么个没用法?

解决方案 »

  1.   

    我就经常将Context放在别的地方,也没有怎么不行啊...
      

  2.   

    TO: GFox(小狐) 请你看好我的问题好吗?害我跑进来白看,晕死
      

  3.   

    晕。改一下Host就行了      <Host name="localhost" debug="0" 
           appBase="D:/developer/jakarta-tomcat-5.5.1/webapps/ROOT"
           unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
      

  4.   

    你可以在server.xml中找到<!-- Tomcat Root Context -->
    然后再其后面加上一句
             <Context path="" docBase="E:\JIA" debug="5" reloadable="true" crossContext="true">
            </Context> 这样的话默认输入http://localhost:8080就可以显示你自己的webapp了,还有为了更加清晰的设置各个webapp,从tomcat5以后,都可以在%tomcat_home%\conf\Catalina\localhost目录下创建自己的webapp配置文件,不用都去server.xml中创建更改了。
      

  5.   

    楼上的正确! 
    本人也是这样做的!
    而且本人的一个tomcat启动两个不同的web服务(都是根目录,访问端口不同,分别人8080和8888),每个服务连接数据连接池也不一样.....
      

  6.   

    如果Tomcat安装在D:\在D:\Tmocat4.1\conf 目录下,用记事本打开server.xml找到如下代码:
    <!-- Tomcat Examples Context -->
            <Context path="/examples" docBase="examples" debug="0"
                     reloadable="true" crossContext="true"><Context path="/fly" docBase="E:\JIA " debug="0"
                     reloadable="true" crossContext="true">在此处设了虚拟目录fly,对应的实际目录E:\JIA ,实际目录存放你的jsp文件,以后要执行这些jsp文件,要先启动
    Tomcat,然后打开IE,在地址兰输入:http://localhost:8080/fly 即可
      

  7.   

    各位,Tomcat4.1与Tomcat5.5.1是不同的。
      

  8.   

    //各位,Tomcat4.1与Tomcat5.5.1是不同的。没人说它们相同呀,但是在context方面如果你按照相同的设置也不会出错。
    只不过tomcat5以后都可以分别建立xml文件进行设置,比较清晰,上面我已经说了。
      

  9.   

    在目录
        Catalina--|
                  localhost--|
                             manager.xml------手动加过context标签,没用
    增加一个xml文件,如JIA.xml
    内容:<?xml version='1.0' encoding='utf-8'?>
    <Context docBase="E:/JIA" path="/JIA" privileged="true" workDir="work\Catalina\localhost\test">
    </Context>就可以用:http://127.0.0.1:8080/JIA 访问了
      

  10.   

    tomcat配置路径就是修改Context来实现的,
    楼主如果配置有问题不能简单地说不行,
    请仔细查看tomcat控制台的出错信息,以确认问题出在哪里。
      

  11.   

    我一直很尊重那些认真看问题,回答问题和讨论问题的朋友,但我发现很多人连问题都看不明白就乱回答,是为了讨论,还是为了捞取专家分?这些人真的让人很失望,而且回复多了,别人都以为解决问题了,真的很耽误事我希望回复帖子的人,也请给别人一点尊重,好吗?----------------------------------------------------------------------------------------你是来问问题的,还是来胡闹的?我不知道别人怎么办的,至少我自己是测试以后才回帖的。
    如果你不相信别人,你自己去看tomcat的文档好了,所有的配置上面写的很清楚,
    这样基本的问题还来问,你是不是要大家手把手教给你,你才能明白怎么回事。
      

  12.   

    TO flyforlove(为情飞) :首先谢谢你对问题的帮助,但请你看好问题再和我讨论,我只回你一次!!为这个问题我已经开了N个帖子,撒几百的分,很多人连问题都不看就回复,如果以前的办法能解决,我何必来这里请教高人?想帮助别人是好事,但一定要有针对性,不然把帖子回复的很长,那些真懂的人看见很多回复,根本不会进来回答了,我希望就事论事,不要谈及其它什么胡闹等问题,如果你测试了,请问你是用我所室的版本下测试的吗?否则请测试完再告诉我,将不胜感激!
      

  13.   

    上面说的配置都没错,urchinjj(懒刺猬)你自已不明白而已!
      

  14.   

    完全同意 yzh315(yzh) 的方法,绝对正确,我就是这样用的
    也同意 ljrong(along) 的说法,urchinjj(懒刺猬),你自己看不明白而已
      

  15.   

    TO ljrong(along) :我从没说他们建议的配置有错,请你看好我的问题!!什么叫对症!TOMCAT5.5.1英文文档我们已经看了好几次,也许是没找到它说的问题关键,但至少没有发现解决的办法,至于其他的,如果你愿意,请搜索我的名字,看看回复我几个帖的情况,,,我一再强调我的server里没有context标签,可很多人连标题都不看就回复,我不知道如何评论这样的回复!我想我问题说的非常清楚,如果再不管为了解释问题去回复,真的不知道怎么说了,无论如何,谢谢你的关注,但如果不是讨论问题,请不要和我讨论题外问题吧,谢谢理解!
      

  16.   

    to urchinjj(懒刺猬) 
    用 yzh315(yzh)的方法你的1,2两个问题都可以解决,我就是这样用的,我的jsp与tomcat不在一个分区,使用http://localhost:8080显示的也是我自己的jsp页面,不是默认的那一个,我用的是Tomcat 5.0.25
      

  17.   

    还有解决你的1,2两个问题根本就不用修改server.xml,tomcat 5.0.25是这样,5.5.1没有用过
      

  18.   

    to urchinjj(懒刺猬) 
    在Tomcat 5.0\conf\Catalina\localhost下面添加JIA.xml,内容如下:<?xml version='1.0' encoding='utf-8'?>
    <Context docBase="e:/JIA" path="/" reloadable="true">
    </Context>然后重新启动你的tomcat,我测试过了,绝对可行,你的1,2两个问题都可以解决
      

  19.   

    to urchinjj(懒刺猬) :
    刚下载tomcat5.5,按上面方法随便配就可以了,不知你怎么搞的.受不了!!把你的server.xml公布一下吧,别犯低别错误还牛气十足!!!!
      

  20.   

    TO fatcatman() ( :按你的指点,我在D:\developer\jakarta-tomcat-5.5.1\conf\Catalina\localhost下新增加文件,内容如下(为避免出错,完全复制你的)<?xml  version='1.0'  encoding='utf-8'?  >  
    <Context  docBase="e:/jia" path="/" reloadable="true">  
    </Context  >  然后关机,重新启动机器,启动TOMCAT,打开IE,打如:localhost:8080  依然显示TOMCAT默认网页我的E盘目录:
    e;\jia
          |
          WEB-INF
          index.jspindex.jsp 上只有一句话,为了测试是否方法可行如果你愿意请加我的MSN;[email protected]虽然问题没解决,谢谢你的关注和认真,我们这个项目是个国际项目,但并不是主要做程序开发,所以开发程序方面不是强项,但程序又是不可少的,所以非常希望得到大家的帮助,等项目结束,我会告诉帮助过我的朋友,我相信大家不会后悔如果我哪里得罪了大家,请原谅,,但我很着急
      

  21.   

    TO ljrong(along) ( 首先谢谢你,但我要声明,我们从来没牛,因为知道自己不会,但解决不了问题,确实很着急,我的serve.xml文件内容如下:如果愿意,请加我的MSN:[email protected]
    <!-- Example Server Configuration File -->
    <!-- Note that component elements are nested corresponding to their
         parent-child relationships with each other --><!-- A "Server" is a singleton element that represents the entire JVM,
         which may contain one or more "Service" instances.  The Server
         listens for a shutdown command on the indicated port.     Note:  A "Server" is not itself a "Container", so you may not
         define subcomponents such as "Valves" or "Loggers" at this level.
     --><Server port="8005" shutdown="SHUTDOWN" debug="0">
      <!-- Comment these entries out to disable JMX MBeans support -->
      <!-- You may also configure custom components (e.g. Valves/Realms) by 
           including your own mbean-descriptor file(s), and setting the 
           "descriptors" attribute to point to a ';' seperated list of paths
           (in the ClassLoader sense) of files to add to the default list.
           e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
      -->
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
                debug="0"/>
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
                debug="0"/>  <!-- Global JNDI resources -->
      <GlobalNamingResources>    <!-- Test entry for demonstration purposes -->
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>    <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users -->
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
           description="User database that can be updated and saved"
               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />  </GlobalNamingResources>  <!-- A "Service" is a collection of one or more "Connectors" that share
           a single "Container" (and therefore the web applications visible
           within that Container).  Normally, that Container is an "Engine",
           but this is not required.       Note:  A "Service" is not itself a "Container", so you may not
           define subcomponents such as "Valves" or "Loggers" at this level.
       -->  <!-- Define the Tomcat Stand-Alone Service -->
      <Service name="Catalina">    <!-- A "Connector" represents an endpoint by which requests are received
             and responses are returned.  Each Connector passes requests on to the
             associated "Container" (normally an Engine) for processing.         By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
             You can also enable an SSL HTTP/1.1 Connector on port 8443 by
             following the instructions below and uncommenting the second Connector
             entry.  SSL support requires the following steps (see the SSL Config
             HOWTO in the Tomcat 5 documentation bundle for more detailed
             instructions):
             * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
               later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
             * Execute:
                 %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
                 $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
               with a password value of "changeit" for both the certificate and
               the keystore itself.         By default, DNS lookups are enabled when a web application calls
             request.getRemoteHost().  This can have an adverse impact on
             performance, so you can disable it by setting the
             "enableLookups" attribute to "false".  When DNS lookups are disabled,
             request.getRemoteHost() will return the String version of the
             IP address of the remote client.
        -->
      

  22.   

    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
        <Connector port="8080"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
                   disableUploadTimeout="true" />
        <!-- Note : To disable connection timeouts, set connectionTimeout value
         to 0 -->

    <!-- Note : To use gzip compression you could set the following properties :

       compression="on" 
       compressionMinSize="2048" 
       noCompressionUserAgents="gozilla, traviata" 
       compressableMimeType="text/html,text/xml"
    -->    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
        <!--
        <Connector port="8443" 
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" disableUploadTimeout="true"
                   acceptCount="100" debug="0" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLS" />
        -->    <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" 
                   enableLookups="false" redirectPort="8443" debug="0"
                   protocol="AJP/1.3" />    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
        <!-- See proxy documentation for more information about using this. -->
        <!--
        <Connector port="8082" 
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false"
                   acceptCount="100" debug="0" connectionTimeout="20000"
                   proxyPort="80" disableUploadTimeout="true" />
        -->    <!-- An Engine represents the entry point (within Catalina) that processes
             every request.  The Engine implementation for Tomcat stand alone
             analyzes the HTTP headers included with the request, and passes them
             on to the appropriate Host (virtual host). -->    <!-- You should set jvmRoute to support load-balancing via AJP ie :
        <Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm1">         
        --> 
             
        <!-- Define the top level container in our container hierarchy -->
        <Engine name="Catalina" defaultHost="localhost" debug="0">      <!-- The request dumper valve dumps useful debugging information about
               the request headers and cookies that were received, and the response
               headers and cookies that were sent, for all requests received by
               this instance of Tomcat.  If you care only about requests to a
               particular virtual host, or a particular application, nest this
               element inside the corresponding <Host> or <Context> entry instead.           For a similar mechanism that is portable to all Servlet 2.4
               containers, check out the "RequestDumperFilter" Filter in the
               example application (the source for this filter may be found in
               "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").           Request dumping is disabled by default.  Uncomment the following
               element to enable it. -->
          <!--
          <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
          -->      <!-- Because this Realm is here, an instance will be shared globally -->      <!-- This Realm uses the UserDatabase configured in the global JNDI
               resources under the key "UserDatabase".  Any edits
               that are performed against this UserDatabase are immediately
               available for use by the Realm.  -->
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                     debug="0" resourceName="UserDatabase"/>      <!-- Comment out the old realm but leave here for now in case we
               need to go back quickly -->
          <!--
          <Realm className="org.apache.catalina.realm.MemoryRealm" />
          -->      <!-- Replace the above Realm with one of the following to get a Realm
               stored in a database and accessed via JDBC -->
      

  23.   

    to urchinjj(懒刺猬) 
    你有可能已经把server.xml改坏了,你重新安装一次tomcat试一下,我没有用MSN,你用QQ吗?我的QQ号是286737731,欢迎讨论,:)
      

  24.   


         <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
                 driverName="org.gjt.mm.mysql.Driver"
              connectionURL="jdbc:mysql://localhost/authority"
             connectionName="test" connectionPassword="test"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->      <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
                 driverName="oracle.jdbc.driver.OracleDriver"
              connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
             connectionName="scott" connectionPassword="tiger"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->      <!--
          <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
                 driverName="sun.jdbc.odbc.JdbcOdbcDriver"
              connectionURL="jdbc:odbc:CATALINA"
                  userTable="users" userNameCol="user_name" userCredCol="user_pass"
              userRoleTable="user_roles" roleNameCol="role_name" />
          -->      <!-- Define the default virtual host
               Note: XML Schema validation will not work with Xerces 2.2.
           -->
          <Host name="localhost" debug="0" appBase="webapps"
           unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false">
           
      
    Context path="" docBase="E:\jia" debug="0" reloadable="true" crossContext="true"/>,       
        <!-- Defines a cluster for this node,
                 By defining this element, means that every manager will be changed.
                 So when running a cluster, only make sure that you have webapps in there
                 that need to be clustered and remove the other ones.
                 A cluster has the following parameters:             className = the fully qualified name of the cluster class             name = a descriptive name for your cluster, can be anything             debug = the debug level, higher means more output             mcastAddr = the multicast address, has to be the same for all the nodes             mcastPort = the multicast port, has to be the same for all the nodes
                 
                 mcastBindAddr = bind the multicast socket to a specific address
                 
                 mcastTTL = the multicast TTL if you want to limit your broadcast
                 
                 mcastSoTimeout = the multicast readtimeout              mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat             mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received             tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes              tcpListenAddress = the listen address (bind address) for TCP cluster request on this host, 
                                    in case of multiple ethernet cards.
                                    auto means that address becomes
                                    InetAddress.getLocalHost().getHostAddress()             tcpListenPort = the tcp listen port             tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
                                      has a wakup bug in java.nio. Set to 0 for no timeout             printToScreen = true means that managers will also print to std.out             expireSessionsOnShutdown = true means that              useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
                                false means to replicate the session after each request.
                                false means that replication would work for the following piece of code:
                                <%
                                HashMap map = (HashMap)session.getAttribute("map");
                                map.put("key","value");
                                %>
                 replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
                                   * Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
                                   * Synchronous means that the thread that executes the request, is also the
                                   thread the replicates the data to the other nodes, and will not return until all
                                   nodes have received the information.
                                   * Asynchronous means that there is a specific 'sender' thread for each cluster node,
                                   so the request thread will queue the replication request into a "smart" queue,
                                   and then return to the client.
                                   The "smart" queue is a queue where when a session is added to the queue, and the same session
                                   already exists in the queue from a previous request, that session will be replaced
                                   in the queue instead of replicating two requests. This almost never happens, unless there is a 
                                   large network delay.
            -->
      

  25.   

    <!--
                When configuring for clustering, you also add in a valve to catch all the requests
                coming in, at the end of the request, the session may or may not be replicated.
                A session is replicated if and only if all the conditions are met:
                1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
                2. a session exists (has been created)
                3. the request is not trapped by the "filter" attribute            The filter attribute is to filter out requests that could not modify the session,
                hence we don't replicate the session after the end of this request.
                The filter is negative, ie, anything you put in the filter, you mean to filter out,
                ie, no replication will be done on requests that match one of the filters.
                The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.            filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
                ending with .gif and .js are intercepted.
                
                The deployer element can be used to deploy apps cluster wide.
                Currently the deployment only deploys/undeploys to working members in the cluster
                so no WARs are copied upons startup of a broken node.
                The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
                When a new war file is added the war gets deployed to the local instance,
                and then deployed to the other instances in the cluster.
                When a war file is deleted from the watchDir the war is undeployed locally 
                and cluster wide
            -->
            
            <!--
            <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
                     managerClassName="org.apache.catalina.cluster.session.DeltaManager"
                     expireSessionsOnShutdown="false"
                     useDirtyFlag="true">            <Membership 
                    className="org.apache.catalina.cluster.mcast.McastService"
                    mcastAddr="228.0.0.4"
                    mcastPort="45564"
                    mcastFrequency="500"
                    mcastDropTime="3000"/>            <Receiver 
                    className="org.apache.catalina.cluster.tcp.ReplicationListener"
                    tcpListenAddress="auto"
                    tcpListenPort="4001"
                    tcpSelectorTimeout="100"
                    tcpThreadCount="6"/>            <Sender
                    className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                    replicationMode="pooled"/>            <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
                       filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
                       
                <Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
                          tempDir="/tmp/war-temp/"
                          deployDir="/tmp/war-deploy/"
                          watchDir="/tmp/war-listen/"
                          watchEnabled="false"/>
            </Cluster>
            -->                <!-- Normally, users must authenticate themselves to each web app
                 individually.  Uncomment the following entry if you would like
                 a user to be authenticated the first time they encounter a
                 resource protected by a security constraint, and then have that
                 user identity maintained across *all* web applications contained
                 in this virtual host. -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn"
                       debug="0"/>
            -->        <!-- Access log processes all requests for this virtual host.  By
                 default, log files are created in the "logs" directory relative to
                 $CATALINA_HOME.  If you wish, you can specify a different
                 directory with the "directory" attribute.  Specify either a relative
                 (to $CATALINA_HOME) or absolute path to the desired directory.
            -->
            <!--
            <Valve className="org.apache.catalina.valves.AccessLogValve"
                     directory="logs"  prefix="localhost_access_log." suffix=".txt"
                     pattern="common" resolveHosts="false"/>
            -->      </Host>    </Engine>  </Service></Server>