Share via


Understanding IIS HTTPPlatformHandler using Tomcat 8

In this article we will understand how to setup HTTPPlatformHandler using Tomcat 8.

Note: In my below example I have used some hard coded value for simplicity for viewer to follow and can be changed based on the need.

 

Step 1: Download Tomcat 8

Go to the URL https://tomcat.apache.org/download-80.cgi and download the zipped package to any of your choice directory, let’s say “C:\JavaSample\bin”.

Once you download the zip file, you can extract into the same location “C:\JavaSample\bin\apache-tomcat-8.0.28\apache-tomcat-8.0.28" which I would refer this as my Tomcat Installation directory called as “TOMCAT_HOME” or CATALINA_HOME.

Catalina is codename for Tomcat 5 and above.

Step 2: Download and Install Java Development Kit

Go to URL https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and download Java development kit 8 for windows based on the bitness of the machine.

Step 3: Creating Environmental Variables for Windows

  • Create an Environmental Variable called CATALINA_HOME with value as your Tomcat installation directory. In my example I have created a server variable CATALINA_HOME= C:\JavaSample\bin\apache-tomcat-8.0.28\apache-tomcat-8.0.28.
    To confirm open command prompt and check if it has been set correctly.

              

  • Take a note of location where your Java Development(JDK) is installed and create a environmental variable called “JAVA_HOME” and set the value to the JDK installed directory. In my example I have set JAVA_HOME=”C:\Program Files\Java\jdk1.8.0_65".
    To confirm open command prompt and check if it has been set correctly.

            

 

Step 3: Configure Apache Tomcat Server

There are few configuration changes required to setup Tomcat server and in our case we will be changing below files under %CATALINA_HOME%\Conf:

  1. Server.xml
  2. Web.xml
  3. Context.xml

Open server.xml under %CATALINA_HOME%\conf and change the settings as high lightened in yellow:

 

<Connector port="${port.http}" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

 

Open web.xml under %CATALINA_HOME%\conf and change the settings as high lightened in yellow:

 

<servlet>

        <servlet-name>default</servlet-name>

        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

        <init-param>

            <param-name>debug</param-name>

            <param-value>0</param-value>

        </init-param>

        <init-param>

            <param-name>listings</param-name>

            <param-value>true</param-value>

        </init-param>

        <load-on-startup>1</load-on-startup>

    </servlet>

 

Open context.xml under %CATALINA_HOME%\conf and change the settings as high lightened in yellow:

 

<Context reloadable="true">

 

 

Step 4: Deploy a Java Servlet

In my case, I have used one of the open source Java Servlet and download the code from https://pebble.sourceforge.net/ and copy the pebble.war from the source code to %CATALINA_HOME%\webapps

Step 5: Configure IIS

  • Install the HttpPlatformHandler – WebPI/x86/x64.
  • Create a website and complete the site as below settings:

             

  • Create a web.config under your website folder which is c:\JavaSample\web.config and add the httpPlatformHandler configuration as below.

   

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <handlers>

      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />

    </handlers>

    <httpPlatform processPath="C:\JavaSample\bin\apache-tomcat-8.0.28\apache-tomcat-8.0.28\bin\startup.bat"     arguments="" stdoutLogEnabled="true" stdoutLogFile="\\?c:\JavaSample\log.txt">

      <environmentVariables>

        <environmentVariable name="JRE_HOME" value="%programfiles%\java\jdk1.8.0_65" />

        <environmentVariable name="CATALINA_HOME" value="c:\JavaSample\bin\apache-tomcat-8.0.28\apache-tomcat-8.0.28" />

                <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT% -Dsomeotherconfig=value" />

      </environmentVariables>

    </httpPlatform>

  </system.webServer>

</configuration>

 

 

Now open a browser and browse  https://localhost which should show the default Tomcat server's welcome page and then browse https://localhost/pebble which should show the website which is deployed under webapps which is served from Tomcat server.

 

References:

https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html

https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-httpplatformhandler-module-for-iis-8/

Comments

  • Anonymous
    November 27, 2015
    Very useful info