web.xml deployment descriptor elements
this following sections describe the deployment descriptor elements defined in the web.xml file. the root element for web.xml is <web-app>. the following elements are defined within the <web-app> element:
- icon element
- <small-icon>
- <large-icon>
- display-name element
- description element
- distributable element
- context-param element
- <param-name>
- <param-value>
- <description>
- filter element
- <icon>
- <filter-name>
- <display-name>
- <description>
- <filter-class>
- <init-param>
- <display-name>
- filter-mapping element
- <filter-name>
- <url-pattern>
- <servlet>
- listener element
- <listener-class>
- servlet element
- <icon>
- <small-icon>
- <large-icon>
- <servlet-name>
- <display-name>
- <description>
- <servlet-class>
- <jsp-file>
- <init-param>
- <description>
- <param-name>
- <param-value>
- <description>
- <load-on-startup>
- <security-role- ref>
- <description>
- <role-name>
- <role-link>
- servlet-mapping element
- <servlet-name>
- <url-pattern>
- session-config element
- <session-timeout>
- mime-mapping element
- <extension>
- <mime-type>
- welcome-file-list element
- <welcome-file>
- error-page element
- <error-code>
- <exception-type>
- <location>
- taglib element
- <taglib-location>
- <taglib-uri>
- resource-ref element
- <description>
- <res-ref-name>
- <res-type>
- <res-auth>
- <res-sharing-scope>
- <res-type>
- security-constraint element
- <web-resource- collection>
- <web-resource- name>
- <description>
- <url-pattern>
- <http-method>
- <url-pattern>
- <auth-constraint>
- <description>
- <role-name>
- <user-data- constraint>
- <description>
- <transport- guarantee>
- login-config element
- <auth-method>
- <realm-name>
- <form-login- config>
- <form-login-page>
- <form-error-page>
- security-role element
- <description>
- <role-name>
- env-entry element
- <description>
- <env-entry-name>
- <env-entry-value>
- <env-entry-type>
- <env-entry-value>
- ejb-ref element
- <description>
- <ejb-ref-name>
- <ejb-ref-type>
- <home>
- <remote>
- <ejb-link>
- <run-as>
- <ejb-ref-type>
icon element
the icon element specifies the location within the web application for a small and large image used to represent the web application in a gui tool. (the servlet element also has an element called the icon element, used to supply an icon to represent a servlet in a gui tool.)
this element is not currently used by weblogic server.
the following table describes the elements you can define within an icon element.
element | required/ | description |
|---|---|---|
<small-icon> | optional | location for a small (16x16 pixel) .gif or .jpg image used to represent the web application in a gui tool. currently, this is not used by weblogic server. |
<large-icon> | optional | location for a large (32x32 pixel) .gif or .jpg image used to represent the web application in a gui tool. currently, this element is not used by weblogic server. |
display-name element
the optional display-name element specifies the web application display name, a short name that can be displayed by gui tools.
element | required/ | description |
<display-name> | optional | currently, this element is not used by weblogic server. |
description element
the optional description element provides descriptive text about the web application.
element | required/ | description |
<description> | optional | currently, this element is not used by weblogic server. |
distributable element
the distributable element is not used by weblogic server.
element | required/ | description |
<distributable> | optional | currently, this element is not used by weblogic server. |
context-param element
the optional context-param element declares a web application's servlet context initialization parameters. you set each context-param within a single context-param element, using <param-name> and <param-value> elements. you can access these parameters in your code using the javax.servlet.servletcontext.getinitparameter() and javax.servlet.servletcontext.getinitparameternames() methods.
the following table describes the elements you can define within a context-param element.
element | required/ | description |
|---|---|---|
<param-name> | required | the name of a parameter. |
<param-value> | required | the value of a parameter. |
<description> | optional | a text description of a parameter. |
filter element
the filter element defines a filter class and its initialization parameters. for more information on filters, see configuring filters.
the following table describes the elements you can define within a servlet element.
element | required/ | description |
|---|---|---|
<icon> | optional | specifies the location within the web application for a small and large image used to represent the filter in a gui tool. contains a small-icon and large-icon element. currently, this element is not used by weblogic server. |
<filter-name> | required | defines the name of the filter, used to reference the filter definition elsewhere in the deployment descriptor. |
<display-name> | optional | a short name intended to be displayed by gui tools. |
<description> | optional | a text description of the filter. |
<filter-class> | required | the fully-qualified class name of the filter. |
<init-param> | optional | contains a name/value pair as an initialization parameter of the filter. use a separate set of <init-param> tags for each parameter. |
filter-mapping element
the following table describes the elements you can define within a filter-mapping element.
element | required/ | description |
|---|---|---|
<filter-name> | required | the name of the filter to which you are mapping a url pattern or servlet. this name corresponds to the name assigned in the <filter> element with the <filter-name> element. |
<url-pattern> | required - or map by <servlet> | describes a pattern used to resolve urls. the portion of the url after the http://host:port + contextpath is compared to the <url-pattern> by weblogic server. if the patterns match, the filter mapped in this element is called. example patterns: /soda/grape/* the url must follow the rules specified in section 10 of the servlet 2.2 specification. |
<servlet> | required - or map by <url-pattern> | the name of a servlet which, if called, causes this filter to execute. |
listener element
define an application listener using the listener element.
element | required/ | description |
|---|---|---|
<listener-class> | optional | name of the class that responds to a web application event. |
for more information, see configuring an event listener.
servlet element
the servlet element contains the declarative data of a servlet.
if a jsp-file is specified and the <load-on-startup> element is present, then the jsp is precompiled and loaded when weblogic server starts.
the following table describes the elements you can define within a servlet element.
element | required/ | description |
|---|---|---|
<icon> | optional | location within the web application for a small and large image used to represent the servlet in a gui tool. contains a small-icon and large-icon element. currently, this element is not used by weblogic server. |
<servlet-name> | required | defines the canonical name of the servlet, used to reference the servlet definition elsewhere in the deployment descriptor. |
<display-name> | optional | a short name intended to be displayed by gui tools. |
<description> | optional | a text description of the servlet. |
<servlet-class> | required (or use <jsp- | the fully-qualified class name of the servlet. use only one of either the <servlet-class> tags or <jsp-file> tags in your servlet body. |
<jsp-file> | required (or use <servlet- | the full path to a jsp file within the web application, relative to the web application root directory. use only one of either the <servlet-class> tags or <jsp-file> tags in your servlet body. |
<init-param> | optional | contains a name/value pair as an initialization parameter of the servlet. use a separate set of <init-param> tags for each parameter. |
<load-on-startup> | require | weblogic server initializes this servlet when weblogic server starts up. the content of this element must be a positive integer indicating the order in which the servlet should be loaded. lower integers are loaded before higher integers. if no value is specified, or if the value specified is not a positive integer, weblogic server can load the servlet in any order in the startup sequence. |
<security-role- | optional | used to link a security role name defined by <security-role> to an alternative role name that is hard coded in the servlet logic. this extra layer of abstraction allows the servlet to be configured at deployment without changing servlet code. |
icon element
this is an element within the servlet element.
the icon element specifies the location within the web application for small and large images used to represent the servlet in a gui tool.
the following table describes the elements you can define within an icon element.
element | required/ | description |
|---|---|---|
<small-icon> | optional | specifies the location within the web application for a small (16x16 pixel) .gif or .jpg image used to represent the servlet in a gui tool. currently, this element is not used by weblogic server. |
<large-icon> | optional | specifies the location within the web application for a small (32x32 pixel) .gif or .jpg image used to represent the servlet in a gui tool. currently, this element is not used by weblogic server. |
init-param element
this is an element within the servlet element.
the optional init-param element contains a name/value pair as an initialization parameter of the servlet. use a separate set of init-param tags for each parameter.
you can access these parameters with the javax.servlet.servletconfig.getinitparameter() method.
the following table describes the elements you can define within a init-param element.
element | required/ | description |
|---|---|---|
<param-name> | required | defines the name of this parameter. |
<param-value> | required | defines a string value for this parameter. |
<description> | optional | text description of the initialization parameter. |
weblogic server recognizes the special initialization parameter, wl-dispatch-policy, to assign a servlet or jsp to an available execute queue. for example, the following example assigns a servlet to use the execute threads available in an execute queue named criticalwebapp:
<servlet> ... <init-param> <param-name>wl-dispatch-policy</param-name> <param-value>criticalwebapp</param-value> </init-param></servlet>
if the criticalwebapp queue is not available, the servlet will use execute threads available in the default weblogic server execute queue. see setting thread count for more information about configuring execute threads in weblogic server. see using execute queues to control thread usage for more information about creating and using queues.
security-role-ref element
this is an element within the servlet element.
the security-role-ref element links a security role name defined by <security-role> to an alternative role name that is hard-coded in the servlet logic. this extra layer of abstraction allows the servlet to be configured at deployment without changing servlet code.
the following table describes the elements you can define within a security-role-ref element.
element | required/ | description |
|---|---|---|
<description> | optional | text description of the role. |
<role-name> | required | defines the name of the security role or principal that is used in the servlet code. |
<role-link> | required | defines the name of the security role that is defined in a <security-role> element later in the deployment descriptor. |
servlet-mapping element
the servlet-mapping element defines a mapping between a servlet and a url pattern.
the following table describes the elements you can define within a servlet-mapping element.
element | required/ | description |
|---|---|---|
<servlet-name> | required | the name of the servlet to which you are mapping a url pattern. this name corresponds to the name you assigned a servlet in a <servlet> declaration tag. |
<url-pattern> | required | describes a pattern used to resolve urls. the portion of the url after the http://host:port + webappname is compared to the <url-pattern> by weblogic server. if the patterns match, the servlet mapped in this element will be called. example patterns: /soda/grape/* the url must follow the rules specified in section 10 of the servlet 2.2 specification. for additional examples of servlet mapping, see servlet mapping. |
session-config element
the session-config element defines the session parameters for this web application.
the following table describes the element you can define within a session-config element.
element | required/ | description |
|---|---|---|
<session-timeout> | optional | the number of minutes after which sessions in this web application expire. the value set in this element overrides the value set in the timeoutsecs parameter of the <session-descriptor> element in the weblogic-specific deployment descriptor weblogic.xml, unless one of the special values listed here is entered. default value: -2 maximum value: integer.max_value ÷ 60 special values:
for more information, see session-descriptor element. |
mime-mapping element
the mime-mapping element defines a mapping between an extension and a mime type.
the following table describes the elements you can define within a mime-mapping element.
element | required/ | description |
|---|---|---|
<extension> | required | a string describing an extension, for example: txt. |
<mime-type> | required | a string describing the defined mime type, for example: text/plain. the following default mime types are provided with weblogic server (you can override these): setifnone(mimetypesmap, "html", "text/html"); setifnone(mimetypesmap, "htm", "text/html"); setifnone(mimetypesmap, "gif", "image/gif"); setifnone(mimetypesmap, "jpeg", "image/jpeg"); setifnone(mimetypesmap, "jpg", "image/jpeg"); setifnone(mimetypesmap, "pdf", "application/pdf"); setifnone(mimetypesmap, "zip", "application/zip"); setifnone(mimetypesmap, "class", "application/x-java-vm"); setifnone(mimetypesmap, "jar", "application/x-java-archive"); setifnone(mimetypesmap, "ser", "application/x-java-serialized-object"); setifnone(mimetypesmap, "exe", "application/octet-stream"); setifnone(mimetypesmap, "txt", "text/plain"); setifnone(mimetypesmap, "java", "text/plain"); // this is for javawebstart out of the box work setifnone(mimetypesmap, "jnlp", "application/x-java-jnlp-file"); |
welcome-file-list element
the optional welcome-file-list element contains an ordered list of welcome-file elements.
when the url request is a directory name, weblogic server serves the first file specified in this element. if that file is not found, the server then tries the next file in the list.
for more information, see configuring welcome pages and how weblogic server resolves http requests.
the following table describes the element you can define within a welcome-file-list element.
element | required/ | description |
|---|---|---|
<welcome-file> | optional | file name to use as a default welcome file, such as index.html |
error-page element
the optional error-page element specifies a mapping between an error code or exception type to the path of a resource in the web application.
when an error occurs—while weblogic server is responding to an http request, or as a result of a java exception—weblogic server returns an html page that displays either the http error code or a page containing the java error message. you can define your own html page to be displayed in place of these default error pages or in response to a java exception.
for more information, see customizing http error responses and how weblogic server resolves http requests.
the following table describes the elements you can define within an error-page element.
note: define either an <error-code> or an <exception-type> but not both.
element | required/ | description |
|---|---|---|
<error-code> | optional | a valid http error code, for example, 404. |
<exception-type> | optional | a fully-qualified class name of a java exception type, for example, java.lang.string |
<location> | required | the location of the resource to display in response to the error. for example, /myerrorpg.html. |
taglib element
the optional taglib element describes a jsp tag library.
this element associates the location of a jsp tag library descriptor (tld) with a uri pattern. although you can specify a tld in your jsp that is relative to the web-inf directory, you can also use the <taglib> tag to configure the tld when deploying your web application. use a separate element for each tld.
the following table describes the elements you can define within a taglib element.
element | required/ | description |
|---|---|---|
<taglib-location> | required | gives the file name of the tag library descriptor relative to the root of the web application. it is a good idea to store the tag library descriptor file under the web-inf directory so it is not publicly available over an http request. |
<taglib-uri> | required | describes a uri, relative to the location of the web.xml document, identifying a tag library used in the web application. if the uri matches the uri string used in the taglib directive on the jsp page, this taglib is used. |
resource-ref element
the optional resource-ref element defines a reference lookup name to an external resource. this allows the servlet code to look up a resource by a "virtual" name that is mapped to the actual location at deployment time.
use a separate <resource-ref> element to define each external resource name. the external resource name is mapped to the actual location name of the resource at deployment time in the weblogic-specific deployment descriptor weblogic.xml.
the following table describes the elements you can define within a resource-ref element.
element | required/ | description |
|---|---|---|
<description> | optional | a text description. |
<res-ref-name> | required | the name of the resource used in the jndi tree. servlets in the web application use this name to look up a reference to the resource. |
<res-type> | required | the java type of the resource that corresponds to the reference name. use the full package name of the java type. |
<res-auth> | required | used to control the resource sign on for security. if set to application, indicates that the application component code performs resource sign on programmatically. if set to container weblogic server uses the security context established with the login-config element. see login-config element. |
<res-sharing-scope> | optional | specifies whether connections obtained through the given resource manager connection factory reference can be shared. valid values:
|
security-constraint element
the security-constraint element defines the access privileges to a collection of resources defined by the <web-resource-collection> element.
for more information, see configuring security in web applications.
the following table describes the elements you can define within a security-constraint element.
element | required/ | description |
|---|---|---|
<web-resource- | required | defines the components of the
扫描关注微信公众号 |
闽公网安备 35060202000074号