CONTENTS   NextPrevious  



Running Apache Web Server with
SAP J2EE Engine 6.20

Apache Web server can handle Web applications with static content only. However, evolving technologies are more likely to use a Web application that includes dynamic Web content. This becomes an issue for those who use Apache Web server. A solution is to run it with a Web server that is capable of serving dynamic pages.

SAP J2EE Engine 6.20 provides a Web server with a functional servlets- and JSP-engine capable of running complex J2EE-based Web applications. It could be used as a backup system to process the dynamic content of the Web application and return the results to the Apache server. In this scenario, no specific configuration or integration tasks should be performed to run the systems together. Communication is based on the simplest client-server model. The Apache server acts as a client by sending a request to SAP J2EE Engine 6.20, and receives a response back. However, some configuration tasks should be performed on Apache Web server to define what kind of requests should be forwarded to the backup system. These are described below.

Configuring Apache Web Server

First, it is assumed that both Apache Web server and SAP J2EE Engine 6.20 are configured and running properly. The next step includes porting the Web application with the corresponding system by deploying it on SAP J2EE Engine 6.20, and copying its directory tree to the Apache document root tree. To learn how to develop a J2EE-based Web application, refer to the Developers Manual in the SAP J2EE Engine 6.20 documentation. For more information about deploying applications on SAP J2EE Engine 6.20, refer to the Deploy Manual .

Note: Do not copy the WEB-INF and meta-inf file to the Apache root tree. By specification, they should not be available to the client, because they contain specific information.

The actual configuration tasks can now be performed. These are completed by editing the main configuration file of the Apache Web server – httpd.conf . The following steps must be completed:

Step 1: Two modules should be enabled and loaded by the Apache Web server. This could be done by adding the following entries to the httpd.conf file:

LoadModule rewrite_module     modules/mod_rewrite.so
LoadModule proxy_module       modules/libproxy.so

AddModule mod_rewrite.c
AddModule mod_proxy.c

RewriteLog "/etc/httpd/logs/rewrite_log"
RewriteLogLevel 9

Note: These entries must be placed in the correct order in the httpd.conf file so that they can take effect.

The rewrite_module is a sophisticated module that provides a powerful way to do URL manipulations. In this case, it rewrites the request that is received by Apache Web server, and creates a new request by observing some rules and sends it to the backup system.

The proxy_module serves as an intermediary between the Apache Web server and SAP J2EE Engine 6.20. Through this module, the response sent back to the client looks as if it was generated by the actual Apache Web server – that is, the presence of the backup system is hidden.

The next two entries refer to the logging properties of the rewrite_module . They specify the name of the log file and the log level, respectively.

Step 2: This involves writing the directives in the httpd.conf file to determine the specific behavior in response to particular type of requests. The directives look like this:

<Location /application_root_dir>

RewriteEngine On

RewriteCond   %{THE_REQUEST} \.jsp
RewriteRule   ^(.+)  http://somehost.com:90%{REQUEST_URI} [P]

RewriteCond %{THE_REQUEST} Example
RewriteRule ^(.+) http://somehost.com:90%{REQUEST_URI} [P]

</Location>

There is an opening tag named <Location> . The root directory of the application should be provided within this tag, starting with a slash. The next line turns on the rewrite engine.

The next couple of lines specify the behavior if a request for a JSP (file with extension .jsp ) is received. In this case, Apache server should send a request to the SAP J2EE Engine 6.20 running on host http://somehost.com and port 90. The [P] key denotes that the proxy_module should handle the response.

The final two lines in this example define similar rule for servlets. In this example, it is assumed that all the servlets that are included in the application contain the string “Example” in their names. Therefore, if a request for a file that contains “Example” in its filename is received, it is forwarded to the SAP J2EE Engine 6.20 running on host http://somehost.com and port 90. The [P] key again denotes that the proxy_module should handle the response.

Note: In this case, there was something common between all servlet classes of the application. If, however, nothing common could be found, there should be a separate couple of entries RewriteCond and RewriteRule for each servlet class.

When all the directives are written, there should be a closing tag </Location> .

Similar code to the one enclosed in <Location> </Location> tags should be provided for each Web application that contains dynamic pages to be processed by Apache Web server.

Previous  Next