Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
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:
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
<?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
Please sign in to use this experience.
Sign in