Contained WithinFind More DocumentationFeatured Support Resources | Scarica il manuale in formato PDF (1277 KB)
Appendix A Deployment Descriptor FilesThis chapter includes the following sections: About Deployment Descriptor FilesThe deployment descriptor conveys the elements and configuration information of a web application between application developers, application assemblers, and deployers. For Java Servlets v.2.5, the deployment descriptor is defined in terms of an XML schema document. Migration IssuesMigration creates a detailed log in the user-specified log file. For every instance, a log is created in the following syntax: MIGRATION_<server instance name>_MMM_DD_YYYY_HH_MM_AM/PM.log. If no log directory exists, the log file is stored at install_dir/admin-server/logs. Java EE Standard DescriptorsThis section describes the Java EE descriptors. sun-web.xmlYou define roles in the deployment descriptor file web.xml and the corresponding role mappings in the sun-web.xml deployment descriptor file for individually deployed web modules. default-web.xmldefault-web.xml is a global web deployment descriptor file that is shared by deployed web applications. It is used to configure the DefaultServlet and JspServlet servlets. In addition, it specifies: MIME mappings based on extensions Welcome files Global filters and security constraints Individual web applications inherit and might override the configuration settings inherited from default-web.xml with their own web.xml. The default-web.xml for each server instance is shared by all web applications deployed on the server instance. Depending on the configuration capabilities of the hosting application, a virtual server might replace the server-wide default-web.xml with its own. In that case, a virtual server's default-web.xml is shared by all web application deployed on the virtual server. Sun Java System Web Server DescriptorsThis section describes the Web Server descriptors. The sun-web-app_2_5-0.dtd FileThe sun-web-app_2_5-0.dtd file defines the structure of the sun-web.xml file, including the elements it can contain and the subelements and attributes these elements can have. The sun-web-app_2_5-0.dtd file is located in the install_dir/lib/dtds directory. Note – Do not edit the sun-web-app_2_5-0.dtd file. Its contents change only with new versions of Web Server. For general information about DTD files and XML, see the XML specification at http://www.w3.org/TR/2004/REC-xml-20040204. Each element defined in a DTD file, which might be present in the corresponding XML file can contain subelements, and attributes described in the following sections. SubelementsElements can contain subelements. For example, the following file fragment defines the cache element: <!ELEMENT cache (cache-helper*, default-helper?, property*, cache-mapping*)> The ELEMENT tag specifies that a cache element can contain cache-helper, default-helper, property, and cache-mapping subelements. The following table shows how optional suffix characters of subelements determine the requirement rules, or number of allowed occurrences, for the subelements. Table A–1 Requirement Rules and Subelement Suffixes
If an element cannot contain other elements, EMPTY or (#PCDATA) appears instead of a list of element names in parentheses. DataSome elements contain character data instead of subelements. These elements have definitions of the following format: <!ELEMENT element-name (#PCDATA)/> For example: <!ELEMENT description (#PCDATA)/> In the sun-web.xml file, white space is treated as part of the data in a data element. Therefore, no extra white space should appear before or after the data delimited by a data element. For example: <description/>class name of session manager</description> AttributesElements that have ATTLIST tags contain attributes (name-value pairs). For example: <!ATTLIST cachemax-capacity CDATA "4096"
timeout CDATA "30"
enabled %boolean; "false">
A cache element can contain max-capacity, timeout, and enabled attributes.
The #REQUIRED label means that a value must be supplied. The #IMPLIED label means that the attribute is optional, and that Web Server generates a default value. Wherever possible, explicit defaults for optional attributes (such as "true") are listed. Attribute declarations specify the type of the attribute. For example, CDATA means character data, and %boolean is a predefined enumeration. Elements in the sun-web.xml FileThis section describes the XML elements in the sun-web.xml file. Elements are grouped as follows: This section also includes an alphabetical list of the elements for quick reference. See Alphabetical List of sun-web.xml Elements. Note – Subelements must be defined in the order in which they are listed in each section, unless otherwise noted. Each sun-web.xml file must begin with the following DOCTYPE header: <!DOCTYPE sun-web-app PUBLIC -//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.5//EN" http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd"> For an alphabetical list of elements in sun-web.xml, see Alphabetical List of sun-web.xml Elements General ElementsGeneral elements are as follows: sun-web-app ElementThis element Web Server- specific configuration for a web application. This element is the root element. The sun-web.xml file contain only one sun-web-app. SubelementsThe following table describes subelements for the sun-web-app element. Table A–2 sun-web-app Subelements
Attributesnone PropertiesThe following table describes the properties for the sun-web-app element. Table A–3 sun-web-app Properties
context-root ElementThis element contains the web context root of the application or web applications. This overrides the corresponding element in the web.xml file. Subelementsnone Attributesnone property ElementSpecifies a property that has a name and a value. A property adds configuration information to its parent element that is:
For example, a manager-properties element can include property subelements: <manager-properties>
<property name="reapIntervalSeconds" value="20" />
</manager-properties>
The properties that manager-properties element uses depends on the value of the parent session-manager element persistence-type attribute. For details, see the description of the session-manager element. SubelementThe following table describes subelement for the property element. Table A–4 property Subelement
AttributesThe following table describes attributes for the property element. Table A–5 property Attributes
description ElementThis element contains a text description of the parent element. Subelementsnone Attributesnone Security ElementsThe security elements are as follows: security-role-mapping ElementThis element maps roles to users or groups in the currently active realm. SubelementsThe following table describes subelements for the security-role-mapping element. Table A–6 security-role-mapping Subelements
Attributesnone servlet ElementThis element specifies a principal name for a servlet, which is used for the run-as role defined in web.xml. SubelementsThe following table describes subelements for the servlet element. Table A–7 servlet Subelements
Attributesnone servlet-name ElementThis element contains data that specifies the name of a servlet, which is matched to a servlet-name in web.xml. This name must be present in web.xml. Subelementsnone Attributesnone role-name ElementThis element contains data that specifies the role-name in the security-role element of the web.xml file. Subelementsnone Attributesnone principal-name ElementThis element contains data that specifies a principal (user) name in the current realm. Subelementsnone Attributesnone group-name ElementThis element contains data that specifies a group name in the current realm. Subelementsnone Attributesnone Session ElementsSession elements are as follows: Note – The session manager interface is unstable. An unstable interface might be experimental or transitional. This interface therefore change change incompatibly, be removed, or be replaced by a more stable interface in the next release. session-config ElementThis element specifies session configuration information. SubelementsThe following table describes subelements for the session-config element. Table A–8 session-config Subelements
Attributesnone session-manager ElementSpecifies session manager information. Note – As of Web Server, you cannot define a session manager either for a single sign-on session or for a virtual server. You must define session managers at the level of web applications. SubelementsThe following table describes subelements for the session-manager element. Table A–9 session-manager Subelements
AttributeThe following table describes the persistence-type attribute for the session-manager element. The left column lists the attribute name, the middle column indicates the default value, and the right column describes what the attribute does. Table A–10 session-manager Attribute
manager-properties ElementThis element specifies session manager properties. SubelementThe following table describes the property subelement for the manager-properties element. Table A–11 manager-properties Subelements
Attributesnone PropertiesThe following table describes properties for the manager-properties element. Table A–12 manager-properties Properties
store-properties ElementSpecifies session persistence (storage) properties. SubelementThe following table describes the property subelement for the store-properties element. Table A–13 store-properties Subelement
Attributesnone PropertiesThe following table describes properties for the store-properties element. Table A–14 store-properties Properties
session-properties ElementThis element specifies session properties. SubelementsThe following table describes the property subelement for the session-properties element. Table A–15 session-properties Subelements
Attributesnone PropertiesThe following table describes properties for the session-properties element. Table A–16 session-properties Properties
cookie-properties ElementThis element specifies session cookie properties. SubelementThe following table describes the property subelement for the cookie-properties element. Table A–17 cookie-properties Subelement
Attributesnone PropertiesThe following table describes properties for the cookie-properties element. Table A–18 cookie-properties Properties
Reference ElementsReference elements are as follows: resource-env-ref ElementThis element maps the res-ref-name Element in the corresponding Java EE web.xml file resource-env-ref entry to the absolute jndi-name of a resource. SubelementsThe following table describes subelements for the resource-env-ref element. Table A–19 resource-env-ref Subelements
Attributesnone resource-env-ref-name ElementContains data that specifies the res-ref-name Element in the corresponding Java EE web.xml file resource-env-ref entry. Subelementsnone Attributesnone service-ref ElementThis element specifies the runtime settings for a web service reference. Runtime information is only needed in the following cases:
service-ref-name ElementThis element specifies the web service reference name relative to java:comp/env. Subelementsnone Attributesnone port-info ElementEither a service-endpoint-interface or a wsdl-port or both ports must be specified. If both ports are specified, wsdl-port specifies the port that the container chooses for container-managed port selection. The same wsdl-port value must not appear in more than one port-info element within the same service-ref. If a service-endpoint-interface is using container-managed port selection, its value must not appear in more than one port-info element within the same service-ref. SubelementsThe following table describes subelements for the port-info element. Table A–21 port-info Subelements
service-endpoint-interface ElementThis element specifies the web service reference name relative to java:comp/env. Subelementsnone Attributesnone wsdl-port ElementSpecifies the WSDL port. SubelementsThe following table describes subelements for the wsdl-port element Table A–22 wsdl-port Subelements
namespaceURI ElementThis element specifies the namespace URI. Subelementsnone Attributesnone localpart ElementSpecifies the local part of a QNAME. Subelementsnone Attributesnone stub-property ElementThis element specifies JAX-RPC property values that are set on a javax.xml.rpc. Stub object before it is returned to the web service client. The property names can be any properties supported by the JAX-RPC Stub implementation. SubelementsThe following table describes subelements for the stub-property element. Table A–23 stub-property subelements
call-property ElementThis element specifies JAX-RPC property values that can be set on a javax.xml.rpc call object before it is returned to the web service client. The property names can be any properties supported by the JAX-RPC Call implementation. Table A–24 call-property Subelements
wsdl-override ElementThis element specifies a valid URL pointing to a final WSDL document. If not specified, the WSDL document associated with the service-ref in the standard J2EE deployment descriptor is used. Subelementsnone Attributesnone service-impl-class ElementSpecifies the name of the generated service implementation class. Subelementsnone Attributesnone service-qname ElementThis element specifies the WSDL service element that is being referred to SubelementsThe following table describes subelements for the service-qname element. Table A–25 service-qname Subelements
resource-ref ElementThis element maps the res-ref-name Element in the corresponding Java EE web.xml file resource-ref entry to the absolute jndi-name Element of a resource. SubelementsThe following table describes subelements for the resource-ref element. The left column lists the subelement name, the middle column indicates the requirement rule, and the right column describes what the element does. Table A–26 resource-ref Subelements
Attributesnone res-ref-name ElementThis element contains data that specifies the res-ref-name in the corresponding Java EE web.xml file resource-ref entry. Subelementsnone Attributesnone default-resource-principal ElementThis element specifies the default principal (user) for the resource. If this element is used in conjunction with a JMS Connection Factory resource, the name and password subelements must be valid entries in Message Queue's broker user repository. SubelementsThe following table describes subelements for the default-resource-principal element. Table A–27 default-resource-principal Subelements
Attributesnone name ElementThis element contains data that specifies the name of the principal. Subelementsnone Attributesnone password ElementThis element contains data that specifies the password for the principal. Subelementsnone Attributesnone jndi-name ElementThis element contains data that specifies the absolute jndi-name of a URL resource or a resource in the server.xml file. Note – To avoid collisions with names of other enterprise resources in JNDI, and to avoid portability problems, all names in a Web Server application should begin with the string java:comp/env. Subelementsnone Attributesnone Caching ElementsFor details about response caching as it pertains to servlets, see Caching Servlet Results and JSP Cache Tags. Caching elements are as follows: cache ElementThis element configures caching for web application components. SubelementsThe following table describes subelements for the cache element. Table A–28 cache Subelements
AttributesThe following table describes attributes for the cache element. Table A–29 cache Attributes
PropertiesThe following table describes properties for the cache element. Table A–30 cache Properties
Cache Class NamesThe following table lists possible values of the cacheClassName property. Table A–31 cacheClassName Values
cache-helper ElementThis element specifies a class that implements the CacheHelper interface. For details, see CacheHelper Interface. SubelementThe following table describes the property subelements for the cache-helper element. Table A–32 cache-helper Subelement
AttributesThe following table describes attributes for the cache-helper element. Table A–33 cache-helper Attributes
default-helperThis element allows you to change the properties of the built-in default cache-helper class. SubelementThe following table describes the property subelements for the default-helper element. Table A–34 default-helper Subelements
Attributesnone PropertyThe following table describes the cacheKeyGeneratorAttrName properties for the default-helper element. Table A–35 default-helper Properties
cache-mapping ElementThis element maps a URL pattern or a servlet name to its cacheability constraints. SubelementsThe following table describes subelements for the cache-mapping element. Table A–36 cache-mapping Subelements
Attributesnone url-pattern ElementThis element contains data that specifies a servlet URL pattern for which caching is enabled. See the Java Servlet 2.5 specification. Subelementsnone Attributesnone cache-helper-ref ElementThis element contains data that specifies the name of the cache-helper used by the parent cache-mapping element. Subelementsnone Attributesnone timeout ElementContains data that specifies the cache-mapping specific maximum amount of time in seconds that an entry can remain in the cache after it is created or refreshed. If not specified, the default is the value of the timeout attribute of the cache element. Subelementsnone AttributesThe following table describes attributes for the timeout element. Table A–37 timeout Attributes
refresh-field ElementThis element specifies a field that gives the application component a programmatic way to refresh a cached entry. Subelementsnone AttributesThe following table describes attributes for the refresh-field element. Table A–38 refresh-field Attributes
http-method ElementThis element contains data that specifies an HTTP method that is eligible for caching. The default is GET. Subelementsnone Attributesnone key-field ElementSpecifies a component of the key used to look up and extract cache entries. The web container looks for the named parameter, or field, in the specified scope. If this element is not present, the web container uses the Servlet Path, the path section that corresponds to the servlet mapping that activated the current request. See the Servlet 2.5 specification, section SRV 4.4, for details on the Servlet Path. Subelementsnone AttributesThe following table describes attributes for the key-field element. Table A–39 key-field Attributes
constraint-field ElementSpecifies a cache ability constraint for the given url-pattern or servlet-name. All constraint-field constraints must pass for a response to be cached. If value constraints are listed, at least one of them must pass. SubelementThe following table describes the value subelements for the constraint-field element. Table A–40 constraint-field Subelements
AttributesThe following table describes attributes for the constraint-field element. Table A–41 constraint-field Attributes
value ElementThis element specifies the value of the entity Subelementsnone Attributesnone Classloader ElementThe Classloader element is named class-loader. class-loader ElementThis element configures the classloader for the web application. Subelementsnone AttributesThe following table describes attributes for the class-loader element. Table A–42 class-loader Attributes
JSP ElementThe JSP elements is jsp-config. jsp-config ElementThis element specifies JSP configuration information that enables web application to customize the compilation and execution of its JSP files. SubelementThe following table describes the name subelement for the jsp-config element. Table A–43 jsp-config Subelements
Attributesnone PropertiesThe following table describes properties for the jsp-config element. Table A–44 jsp-config Properties
The following example illustrates the use of the initial-capacity property described in the table above. The example shows how you would configure a value of 1024: <jsp-config> <property name=”initial-capacity” value=”1024” /></jsp-config> Internationalization ElementsThe internationalization elements are as follows: parameter-encoding ElementThis element specifies a hidden field or default character set that determines the character encoding the web container uses to decode parameters for request.getParameter calls when the character set is not set in the request's Content-Type. For encodings you can use, see http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html. AttributesThe following table describes attributes for the parameter-encoding element. Table A–45 parameter-encoding Attributes
Subelementsnone Attributesnone locale-charset-info ElementSpecifies the mapping between the locale and the character encoding that should be set in the Content-type header of the response if a servlet or JSP sets the response locale using the ServletResponse.setLocale method. This setting overrides the web container's default locale-to-charset mapping. SubelementsThe following table describes subelements for the locale-charset-info element. Table A–46 locale-charset-info Subelements
AttributesThe following table describes the default-locale attributes for the locale-charset-info. Table A–47 locale-charset-info Attributes
locale-charset-map ElementThis element maps a locale to a specific character encoding. For encodings you can use, see: http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html AttributesThe following table describes attributes for the locale-charset-map element. Table A–48 locale-charset-map Attributes
The following table provides a locale-charset-map example, listing the locale and the corresponding charset: Table A–49 locale-charset-map Example
message-destination ElementThis element specifies the name of a logical message-destination defined within an application. The message-destination-name matches the corresponding message-destination-name in the corresponding Java EE deployment descriptor file. SubelementsThe following table describes subelements for the message-destination element. Table A–50 message-destination Subelements
message-destination-name ElementThis element specifies the name of a logical message destination defined within the corresponding Java EE deployment descriptor file. Subelementsnone webservice-description ElementThis element specifies a name and optional publish location for a web service. SubelementsThe following table describes subelements for the webservice-description element Table A–51 webservice-description Subelements
Attributesnone webservice-description-name ElementThis element specifies a unique name for the web service within a web. Subelementsnone Attributesnone wsdl-publish-location ElementThis element specifies the URL of a directory to which a web service's WSDL is published during deployment. Any required files are published to this directory, preserving their location relative to the module-specific WSDL directory (META-INF/wsdl or WEB-INF/wsdl). Subelementsnone Attributesnone Alphabetical List of sun-web.xml ElementsThis section provides an alphabetical list for the easy lookup of sun-web.xml elements. default-resource-principal Element message-destination-name Element message-security-binding Element webservice-description Element webservice-description-name Element Note – For a list of sun-web.xml elements by category, see Elements in the sun-web.xml File. Sample Web Application XML FilesThis section includes sample web.xml and sun-web.xml files Sample web.xml FileThe following is the sample web.xml file. <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.5">- <!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. --> - <web-app> <display-name>webapps-caching</display-name> - <servlet> <servlet-name>ServCache</servlet-name> <servlet-class>samples.webapps.caching.ServCache</servlet-class> <load-on-startup>0</load-on-startup> </servlet> - <servlet-mapping> <servlet-name>ServCache</servlet-name> <url-pattern>/ServCache</url-pattern> </servlet-mapping> - <session-config> <session-timeout>30</session-timeout> </session-config> - <taglib> <taglib-uri>/com/sun/web/taglibs/cache</taglib-uri> <taglib-location>/WEB-INF/sun-web-cache.tld</taglib-location> </taglib> </web-app> Sample sun-web.xml FileThe following example shows a sample sun-web.xml file. <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1
Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
<!--
Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-->
-
<sun-web-app>
-
<session-config>
<session-manager/>
</session-config>
-
<cache enabled="true" timeout-in-seconds="300">
-
<cache-mapping>
<servlet-name>ServCache</servlet-name>
<key-field name="inputtext" scope="request.parameter"/>
-
<constraint-field name="inputtext" scope="request.parameter">
<value>one</value>
<value>two</value>
</constraint-field>
</cache-mapping>
</cache>
</sun-web-app>
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||