uCosminexus Application Server, Web Container Functionality Guide
2.10.4 Definition in the DD
This subsection describes the DD definitions required for using the HTTP response compression functionality.
To enable the HTTP response compression functionality, you must add the filter definition and filter mapping definition in the DD of the Web applications. The HTTP response compression functionality is enabled only when requests exist for the resources with the URL pattern mapped by the filter mapping definition.
Define the HTTP response compression functionality in web.xml.
The following table lists the definition of HTTP response compression functionality in the DD:
Table 2-40 Definition of HTTP response compression functionality in the DD
Settings |
Specified tags |
Setting contents |
Filter definition |
<filter-name> tag in the <filter> tag |
Specify the name of the filter you want to add. The set value is a fixed value.
- Set value (fixed value)
- com.hitachi.software.was.web.ResponseCompressionFilter
|
<filter-class> tag in the <filter> tag |
Specify the class name of the filter you want to add. The set value is a fixed value.
- Set value (fixed value)
- com.hitachi.software.was.web.ResponseCompressionFilter
|
Mapping of the URL pattern and HTTP response compression rules |
<param-name> tag and <param-value> tag in the <filter-class><init-param> tag |
Specify the mapping of the URL pattern and the HTTP response compression functionality.
For details, see 2.10.4(1) Mapping of the URL pattern and HTTP response compression rules (url-mapping). |
HTTP response compression rules |
Specify the compression rule name, Media-Type, and compression threshold as the compression rules for HTTP response.
For details, see 2.10.4(2) HTTP response compression rules. |
Filter mapping definition |
<filter-name> tag in the <filter-mapping> tag |
Specify the filter name. The set value is a fixed value.
- Set value (fixed value)
- com.hitachi.software.was.web.ResponseCompressionFilter
|
<url-pattern> tag in the <filter-mapping> tag |
Specify the mapping of the URL pattern or servlet class and the HTTP response compression filter. The HTTP response compression functionality is enabled only when requests exist for the resources with the URL pattern mapped by the filter mapping definition.
The set value is optional. |
The definition contents of the DD are described in the following examples of the DD definitions:
...
<filter>
<filter-name>com.hitachi.software.was.web.ResponseCompressionFilter</filter-name>
<filter-class>com.hitachi.software.was.web.ResponseCompressionFilter</filter-class>
<init-param>
<param-name>url-mapping</param-name>
<param-value>
/*=rule1;
</param-value>
</init-param>
<init-param>
<param-name>rule1</param-name>
<param-value>
*: 1000;
</param-value>
</init-param>
</filter>
...
<!-- The filter mappings for Response Compression Filter -->
<filter-mapping>
<filter-name>com.hitachi.software.was.web.ResponseCompressionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
|
The part enclosed in the <filter> tag is the filter definition and the part enclosed in the <filter-mapping> tag is the filter mapping definition. The value specified in the <filter-name> tag and <filter-class> tag of the filter definition is fixed in the following package name:
com.hitachi.software.was.web.ResponseCompressionFilter
The contents defined in the <init-param> tag of the DD are as follows:
- Organization of this subsection
- (1) Mapping of the URL pattern and HTTP response compression rules (url-mapping)
- (2) HTTP response compression rules
- (3) Notes
(1) Mapping of the URL pattern and HTTP response compression rules (url-mapping)
The <init-param> tag of the DD specifies the mapping of the URL pattern that enables the HTTP response compression functionality and the name of the HTTP response compression rule applied to the specified URL pattern.
The rules for specifying parameters and the mapping rules for URL pattern are as follows:
(a) Rules for specifying parameters
- The URL pattern is case-sensitive.
- The name of the HTTP response compression rule is case-sensitive.
- The URL pattern and HTTP response compression rule name are delimited by one-byte equal sign (=).
- Delimit multiple specifications with one-byte semicolon (;).
- If multiple URL patterns are applicable, the URL pattern specified earlier is used.
- The linefeed, tabs, and spaces in the parameter value are ignored.
- The one-byte semicolon (;) at the end of the parameter value is ignored.
(b) Mapping rules for URL pattern
The path match, extension match, and exact match mapping rules are applicable to the URL pattern defined in the url-mapping parameter. The following shows the mapping rules:
- Path match
If a string beginning with / and ending with /* is specified as the URL pattern and if the relative path from the context root of the request URL begins with the string excluding * from the URL pattern, the string is considered as matching. Also, if /* is specified as the URL pattern, all the request URLs are considered to be matching.
- Examples:
- In the URL pattern /jsp/*, if the relative path from the context root of the request URL is /jsp/index.jsp, the string is considered as matching.
- Extension match
If a string beginning with *. is specified as the URL pattern and if the string is the same as the string continuing after *. of the request URL extension and URL pattern, the string is considered as matching.
- Example:
- In the URL pattern *.jsp, if the relative path from the context root of the request URL is /jsp/index.jsp, the string is considered to be matching.
- Exact match
If a string other than those mentioned above begins with / as the specified URL pattern and if the relative path from the context root of the request URL is exactly same as this URL pattern, the string is considered as matching.
- Example:
- In the URL pattern /jsp/index.jsp, if the relative path from the context root of the request URL is / jsp/index.jsp, the string is considered as matching.
(2) HTTP response compression rules
The <init-param> tag of the DD specifies the Media-Type of the HTTP response to be compressed and the compression threshold.
- Media-Type
- If the Media-Type specified as the condition is included in the HTTP response, the HTTP response will be compressed with the HTTP response compression functionality.
- Compression threshold
- The compression threshold is specified as an integer value from 100 to 2,147,483,647. By default, compression threshold 100 is applied to the all Media-Type.
- The compression threshold is used for determining whether to compress the HTTP response depending on the size of the HTTP response body. When the size of the HTTP response body exceeds the size defined in the compression threshold, the HTTP response will be compressed with the HTTP response compression functionality.
- When the size of the HTTP response is small, by defining the compression threshold you ensure that the time required for HTTP response compression is not longer than the time required for communication.
- An appropriate size is decided for the compression threshold depending on the type of resources you want to compress and the speed of communications line; therefore, it is recommended that the size defined in the compression threshold be acquired using actual measurements and be defined appropriately.
The following shows the rules for specifying parameters:
- If an asterisk (*) is specified in Media-Type, all Media-Type are shown. However, if each Media-Type is specified, the specification for each Media-Type is given priority.
- Media-Type is case-insensitive.
- Media-Type and compression threshold are delimited with one-byte colon (: ).
- Delimit multiple specifications with one-byte semicolon (;).
- If the same Media-Type is specified multiple times, the Media-Type specified later is used.
- The linefeed, tabs, and spaces in the parameter value are ignored.
- The one-byte semicolon (;) at the end of the parameter value is ignored.
Take the following precautions when you set up the HTTP response compression filter:
- Check the validity of the filter initialization parameter when you initialize the filter for response compression. If a problem occurs in the value defined in the initialization parameter, an error occurs in the filter initialization process and the Web application will not start.
- If the request URL matches the URL pattern specified in the url-mapping parameter, but if the response compression filter does not match the mapped URL pattern, the response compression rules specified in the url-mapping parameter are not applied.
- If multiple URL patterns are mapped to the response compression filter, you need to specify the filter mapping definition in such a way so that the request URL does not match with multiple URL patterns simultaneously. To specify different response compression functionality for multiple URL patterns, specify multiple URL patterns in the url-mapping parameter.
- To use the memory session failover functionality, specify the filter mapping definition of the response compression filter under the filter mapping definition of the filter for session failover.
- If the Web application version is Servlet 2.4 or later versions, do not specify the <dispatcher> tag of <filter-mapping>. Also, if 'FORWARD', 'INCLUDE', and 'ERROR' is specified in the <dispatcher> tag, note that an error will occur while starting the Web application and the application cannot be started.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.