6.7.3 Execution environment settings (J2EE server settings)
This section describes the settings for distributing requests with the redirector.
- Organization of this subsection
(1) Overview
In the in-process HTTP server, you can distribute requests by the URL pattern included in the HTTP request. You can also customize the response for the distributed request and return a specific file to the client. When the response status code for the request to a redirected URL is 300, the response body is auto-generated and the response is returned to the client. Also, you can use a specified file as a response body. When you specify the file, also specify the Content-Type header of the response.
The auto-generated response body is as follows:
<HTML><HEAD> <TITLE>Status code and explanation</TITLE> </HEAD><BODY> <H1>Status code and explanation</H1> </BODY></HTML>
The status code for which the response body is auto-generated and the description is as follows:
-
300 Multiple Choices
-
301 Moved Permanently
-
302 Found
-
303 See Other
-
305 Use Proxy
-
307 Temporary Redirect
When the reading of the file used as the response body during request processing fails, if 300 is specified as the status code, the response body is auto-generated and returned to the client. If 200 is specified as the status code, status 500 error is returned to the client.
(2) How to set
Specify the definition for distributing requests with the redirector in the <configuration> tag of the logical J2EE server (j2ee-server), in the Easy Setup definition file.
The following table lists the definitions in the Easy Setup definition file for distributing requests with the redirector:
Parameter to be specified |
Setting contents |
---|---|
webserver.connector.inprocess_http.redirect.list |
Specifies the redirect definition name. |
webserver.connector.inprocess_http.redirect.redirect-difinition-name.request_url |
Specifies the URL of the redirected request as an absolute path beginning with a forward slash (/). |
webserver.connector.inprocess_http.redirect.redirect-difinition-name.redirect_url |
Specifies the URL for redirecting the request. Note that when 200 is specified as the status code, the URL cannot be specified. |
webserver.connector.inprocess_http.redirect.redirect-difinition-name.status |
Specifies the response status code used when redirection is executed. |
webserver.connector.inprocess_http.redirect.redirect-difinition-name.file |
Specifies the file to be used as the response body when a specific file is returned to the client as a response. Note that when 200 is specified as the status code, the file to be used must be specified. |
webserver.connector.inprocess_http.redirect.redirect-difinition-name.file.content_type |
Specifies the Content-Type header of the file to be used as the response body when a specific file is returned as a response to the client. |
For details on the Easy Setup definition file and parameters to specify, see Part 3 Reference (V9 Compatibility Mode).
- Important note
-
-
When the HTTP response is an HTML file, if another file (such as an image file) is being referenced from that HTML, the file might not be properly displayed in the browser.
-
If the value specified in the redirect URL matches with the value specified for the request URL, note that the client keeps redirecting the requests.
-
When a session is managed by URL rewriting, the session cannot be inherited even if the request is redirected to the same Web application as the request URL.
-
(3) Example settings
An example of settings for request distribution with the redirector is as follows:
-
Setup example 1
An example of request distribution with the redirector is as follows:
... <param> <param-name>webserver.connector.inprocess_http.redirect.list</param-name> <param-value>REDIRECT_1,REDIRECT_2</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_1.request_url</param-name> <param-value>/index.html</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_1.redirect_url</param-name> <param-value>http://host1/new_dir/index.html</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_1.status</param-name> <param-value>302</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_2.request_url</param-name> <param-value>/old_dir/*</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_2.redirect_url</param-name> <param-value>http://host1/new_dir/</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_2.status</param-name> <param-value>301</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_2.file</param-name> <param-value>C:/data/301.html</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_2.file.content_type</param-name> <param-value>text/html; charset=ISO-8859-1</param-value> </param> ...
In this example, REDIRECT_1 and REDIRECT_2 are used as the redirect definition names. In REDIRECT_1, the request to /index.html is redirected to http://host1/new_dir/index.html with status code '302'. In REDIRECT_2, the requests to /old_dir/ are redirected under http://host1/new_dir/ with status '301'. Also, C:/data/301.html is used as the response body and text/html; charset=ISO-8859-1 is used as the Content-Type header.
-
Setup example 2
When a wild card is used as a request URL and a value ending with a forward slash (/) is specified in the redirect URL, the value set in the Location header of the response becomes 'Value specified in the redirect URL' + 'Actual path from the wild card of the request URL'.
... <param> <param-name>webserver.connector.inprocess_http.redirect.list</param-name> <param-value>REDIRECT_3</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_3.request_url</param-name> <param-value>/dir1/*</param-value> </param> <param> <param-name>webserver.connector.inprocess_http.redirect.REDIRECT_3.redirect_url</param-name> <param-value>http://host/dir2/</param-value> </param> ...
In this example, when the actual request URL is /dir1/subdir1/index.html, http://host/dir2/subdir1/index.html is set in the Location header. Note that even when a wild card is used in the request URL, if the redirect URL does not end with a forward slash (/), the value of the Location header is the same as the redirect URL.
When redirect is executed, if a query string is added to the actual request URL, the value set in the Location header is a value wherein the query string is added to the value specified for the redirect URL. You can also specify a value with the query string added in the redirect URL. In this case, if a query string is also added to the actual request URL, the value set in the Location header is a value wherein the request query string is added behind the value specified for the redirect URL.