JKL Toy Company adds dynamic content with server-side includes for HTTP Server
This scenario discusses how to add dynamic content to an IBM® HTTP Server for i Web server using server-side includes.
Scenario
The JKL Toy company (a fictitious company) wants to add some dynamic content to their index file (or welcome page) on their Web site. The welcome Web page is located in /www/jkltest/htdocs. The JKL Web administrator will add the current server time to display on their Web page.
Prerequisites
- It is assumed you have read Scenarios: HTTP Server.
- It is assumed you have read and completed JKL Toy Company creates an HTTP Server or you have an existing HTTP Server configuration.
- It is assumed you have installed and are familiar with System i® Navigator.
Edit the index file (or welcome page) with System i Navigator
For in-depth information on how to use the System i Navigator, read the System i Navigator help installed with the product.
- Start System i Navigator.
- Expand theIBM i server
the HTTP Server is installed on.
Example: JKL_SERVER
- Expand File Systems > Integrated File System > Root >
www > [server_name].
Example: File Systems > Integrated File System > Root > www > jkltest
- Click htdocs.
The directory htdocs is the default name of your document root provided by the Create New HTTP Server wizard.
- Right-click index.html.
- Click Rename.
- Rename the file index.shtml.
- Right-click index.shtml.
- Click Edit.
- Enter the following lines below the <BODY> tag and before
the </BODY> tag:
<p>The current server time is: <!--#config timefmt="%T" --> <!--#echo var="DATE_LOCAL" --> </p>
- Save and close the file.
See Server-side include commands for HTTP Server for more information about SSI commands.
Start the IBM Web Administration for i interface
Access the IBM Web Administration for i from your browser. For information about how to access the Web Administration for i interface, see Starting Web Administration for i.
Set up server-side includes for HTTP Server
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
Example: JKLTEST
- Select Global configuration from the Server area list.
- Expand Server properties.
- Click Container Management.
- Click the Files tab in the form.
- Click Add under the Files/Files Match containers table.
- Select Files Match from the list in the Type column.
- Enter \.shtml(\..+)?$ in the File name or expression column.
- Click Continue.
- Click OK.
- Select Files Match \.shtml(\..+)?$ from the Server area list.
- Expand Server Properties.
- Click Dynamic Content and CGI.
- Click the Server Side Includes tab in the form.
- Select Allow server side files without CGI under Server side includes.
- Click OK.
- Select Global configuration from the Server area list.
- Expand Server Properties.
- Click General Server Configuration.
- Click the Welcome Pages tab in the form.
- Select index.html in the Welcome/index file names table.
- Rename the file index.shtml in the File name column.
- Click Continue.
- Click OK.
Restart your HTTP Server
Select one of the following methods below:
Manage one server
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
- Click the Stop icon if the server is running.
- Click the Start icon.
Manage all servers
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select All Servers from the Server list.
- Click the All HTTP Servers tab.
- Select your HTTP Server name in the table.
Example: JKLTEST
- Click Stop if the server is running.
- Click Start.
Test your HTTP Server
- Start a new Web browser.
- Enter http://[i_hostname]:[port] in the location or URL
field.
Example: http://jkl_server:1975
The Web page now displays the current server time.
View your HTTP Server configuration
Your configuration will look similar if you used the given example in this and previous examples.
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
Example: JKLTEST
- Expand Tools.
- Click Display Configuration File.
Listen *:1975
DocumentRoot /www/jkltest/htdocs
TraceEnable Off
Options -FollowSymLinks
AccessFileName .htaccess
LogFormat "%h %l %u %t \"%r\" %|s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{Cookie}n \"%r\" %t" cookie
LogFormat "%{User-agent}i" agent
LogFormat "%{Referer}i -| %U" referer
LogFormat "%h %l %u %t \"%r\" %|s %b" common
CustomLog logs/access_log combined
LogMaint logs/access_log 7 0
LogMaint logs/error_log 7 0
SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
SetEnvIf "User-Agent" "JDK/1\.0" force-response-1.0
SetEnvIf "User-Agent" "Java/1\.0" force-response-1.0
SetEnvIf "User-Agent" "RealPlayer 4\.0" force-response-1.0
SetEnvIf "User-Agent" "MSIE 4\.0b2;" nokeepalive
SetEnvIf "User-Agent" "MSIE 4\.0b2;" force-response-1.0
DirectoryIndex index.shtml
<Directory />
Require all denied
</Directory>
<Directory /www/jkltest/htdocs>
Require all granted
</Directory>
<FilesMatch \.shtml(\..+)?$>
Options +IncludesNoExec
AddOutputFilter INCLUDES .shtml
</FilesMatch>