Tomcat Context 学习备忘

转自http://www.blogjava.net/caiwen/archive/2007/04/03/108212.html

 

 

 

今天终于搞定Tomcat的Context了,conf/Context.xml是Tomcat公用的环境配置;若在Server.xml中增加的话,则myApp/META-INF/Context.xml就没用了(被server.xml中的Context替代),Jndi 数据源或其他资源可直接定在里面,如:  
   
                                                  type="javax.transaction.UserTransaction"
                                            factory="org.objectweb.jotm.UserTransactionFactory"
                                            jotm.timeout="60" />      
       
                                      password="helloworld" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
                                      maxIdle="2" maxWait="5000" username="sa"
                                      url="jdbc:microsoft:sqlserver://192.168.0.193:1433;DatabaseName=test_cyber3;SelectMethod=cursor" maxActive="4"/>
                                      
      
                                      password="helloworld" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
                                      maxIdle="2" maxWait="5000" username="sa"
                                      url="jdbc:microsoft:sqlserver://192.168.0.193:1433;DatabaseName=test_cyber3" maxActive="4"/>
       
     
;
若在中增加的JNDI或其他的,在App中需引用,才能使用,以下两种引用方式:
  A:在WEB-INF/web.xml 中配置如下:

      DB Connection
      jdbc/TestDB
      javax.sql.DataSource
      Container
 

B:在yoursApp\META-INF\context.xml, 如下:

 
debug="5"   
reloadable="true" 
crossContext="true">

你可能感兴趣的:(j2ee)