TOMCAT JSP WEB-INF META-INF目录详解

最近学习JSP,碰到一些基础性的问题浪费很多时间.重新学习了这些目录的内容.

================================================

WEB-INF

    /WEB-INF/web.xml
        你的Web应用程序配置文件,这是一个XML文件,其中描述了 servlet 和其他的应用组件配置及命名规则;


    /WEB- INF/classes/
        这个目录包含了站点所有用的 class 文件,包括 servlet class 和非servlet class,他们不能包含在 .jar文件中。
        站点的类的存放规则应该按照Java的打包规则执行。例如: 有一个类命名为 com.mycompany.mypackage.MyServlet, 你应该按照以下形式部署: /WEB-INF/classes/com /mycompany/mypackage/MyServlet.class ;
        按照包名结构放置各个类(JavaBean   和   Servlet)  


    /WEB- INF/lib/
        存放web应用需要的各种JAR文件,放置仅在这个应用中要求使用的jar文件,如数据库驱动jar文件


    /WEB- INF/src/
        src=source 源码目录,按照包名结构放置各个java文件


    /WEB- INF/database.properties
        数据库配置文件
            # database.properties
            jdbc.drivers = com.mysql.jdbc.Driver
            jdbc.url = jdbc:mysql://localhost/ams2
            jdbc.username = root
            jdbc.password = psw

            # table define
            ams2.table.dialogue = content_dialogue
            ams2.table.expansion = content_expansion_sentence
            ams2.table.vocabulary = content_vocabulary


    /WEB-INF/tags/
        标签文件库,存放了客户定义的标签文件,该目录并不一定为 tags,用户可以根据自己的喜好和习惯为自己的标签文件库命名,当使用了用户定义的标签文件库名称时,在用户使用标签文件时就必须声明正确的标签文件库路径。例如:当自定义标签文件库名称为 simpleTags 时,在使用 simpleTags 目录下的标签文件时,就必须在 jsp 文件头声明为:<%@ taglib prefix="tags" tagdir="/WEB-INF /simpleTags" % >;


    /WEB-INF/jsp/
        Jsp 1.2 以下版本的文件存放位置。改目录没有特定的声明,同样,用户可以根据自己的喜好与习惯来命名。此目录主要存放的是 Jsp 1.2 以下版本的文件,为区分 Jsp 2.0 文件,通常使用 jsp 命名,当然你也可以命名为 jspOldEdition ;

    /WEB-INF/jsp2/
        与 jsp 文件目录相比,该目录下主要存放 Jsp 2.0 以下版本的文件,当然,它也是可以任意命名的,同样为区别 Jsp 1.2 以下版本的文件目录,通常才命名为 jsp2。


META-INF

    相当于一个信息包,目录中的文件和目录获得Java 2平台的认可与解释,用来配置应用程序、扩展程序、类加载器和服务
    manifest.mf文件,在用jar打包时自动生成

   

     关于context.xml,从apache上找到解释,这个让我着实头痛了好久:

Common Attributes
All implementations of Context support the following attributes:

 

backgroundProcessorDelay This value represents the delay in seconds between the invocation of the backgroundProcess method on this context and its child containers, including all wrappers. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own processing thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the backgroundProcess method on this host and all its child containers. A context will use background processing to perform session expiration and class monitoring for reloading. If not specified, the default value for this attribute is -1, which means the context will rely on the background processing thread of its parent host.
 
className Java class name of the implementation to use. This class must implement the org.apache.catalina.Context interface. If not specified, the standard value (defined below) will be used.
 
cookies Set to true if you want cookies to be used for session identifier communication if supported by the client (this is the default). Set to false if you want to disable the use of cookies for session identifier communication, and rely only on URL rewriting by the application.
 
crossContext Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.
 
docBase The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.

If a symbolic link is used for docBase then changes to the symbolic link will only be effective after a Tomcat restart or by undeploying and redeploying the context. A context reload is not sufficient.

Do not choose a docBase that starts with your Host's appBase string. The default appBase is "webapps" so do not choose a docBase like "webapps-foo." Doing so will lead to deployment errors: see Bugzilla for details.

The value of this field must not be set when the Context is configured using a META-INF/context.xml file as it will be inferred by the automatic deployment process.
 
override Set to true to have explicit settings in this Context element override any corresponding settings in the default settings associated with the owning Host. The default is false.
 
privileged Set to true to allow this context to use container servlets, like the manager servlet. Use of the privileged attribute will change the context's parent class loader to be the Catalina class loader rather than the Shared class loader.
 
path The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.

The value of this field must not be set except when statically defining a Context in server.xml, as it will be inferred from the filenames used for either the .xml context file or the docBase.
 
reloadable Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
 
wrapperClass Java class name of the org.apache.catalina.Wrapper implementation class that will be used for servlets managed by this Context. If not specified, a standard default value will be used.
 
useHttpOnly Should the HttpOnly flag be set on session cookies to prevent client side script from accessing the session ID? Defaults to false.
 
 
Standard Implementation
The standard implementation of Context is org.apache.catalina.core.StandardContext. It supports the following additional attributes (in addition to the common attributes listed above):

 

 

allowLinking If the value of this flag is true, symlinks will be allowed inside the web application, pointing to resources outside the web application base path. If not specified, the default value of the flag is false.

NOTE: This flag MUST NOT be set to true on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.
 
antiJARLocking If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.
 
antiResourceLocking If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.

Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.

Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.
 
cacheMaxSize Maximum size of the static resource cache in kilobytes. If not specified, the default value is 10240 (10 megabytes).
 
cacheTTL Amount of time in milliseconds between cache entries revalidation. If not specified, the default value is 5000 (5 seconds).
 
cachingAllowed If the value of this flag is true, the cache for static resources will be used. If not specified, the default value of the flag is true.
 
caseSensitive If the value of this flag is false, all case sensitivity checks will be disabled. If not specified, the default value of the flag is true.

NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.
 
processTlds Whether the context should process TLDs on startup. The default is true. The false setting is intended for special cases that know in advance TLDs are not part of the webapp.
 
swallowOutput If the value of this flag is true, the bytes output to System.out and System.err by the web application will be redirected to the web application logger. If not specified, the default value of the flag is false.
 
tldNamespaceAware If the value of this flag is true, the TLD files XML validation will be namespace-aware. If you turn this flag on, you should probably also turn tldValidation on. The default value for this flag is false, and setting it to true will incur a performance penalty.
 
tldValidation If the value of this flag is true, the TLD files will be XML validated on context startup. The default value for this flag is false, and setting it to true will incur a performance penalty.
 
unloadDelay Amount of ms that the container will wait for servlets to unload. If not specified, the default value of the flag is 2000 ms.
 
unpackWAR If true, Tomcat will unpack all compressed web applications before running them. If not specified, the default value is true.
 
useNaming Set to true (the default) to have Catalina enable a JNDI InitialContext for this web application that is compatible with Java2 Enterprise Edition (J2EE) platform conventions.
 
workDir Pathname to a scratch directory to be provided by this Context for temporary read-write use by servlets within the associated web application. This directory will be made visible to servlets in the web application by a servlet context attribute (of type java.io.File) named javax.servlet.context.tempdir as described in the Servlet Specification. If not specified, a suitable directory underneath $CATALINA_HOME/work will be provided.
 
 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值