Software Development

CGI with Tomcat 8

This article demonstrates how to configure Apache Tomcat 8 for CGI.

Hardware Environment


Software Environment

  • Windows 7 Professional SP1
  • Any web browser
  • Apache Tomcat 8.0.14
  • ActivePerl (Windows x86)
  • Java 1.7 (1.7.0_67 – Windows x86)

Install Java SE Development Kit 7

1. Download Java SE Development Kit 7 from Oracle

2. Install Java SE Developer Kit 7

3. Verify installation


Install ActivePerl

1. Download ActivePerl from

2. Install ActivePerl

3. Append the c:\<PERL HOME>\bin to %PATH%

This can be done either on the command line where you would also invoke Tomcat or System Properties -> Advanced tab -> Environment Variables -> PATH

3. Verify installation


Download and Extract Apache Tomcat 8

1. Download Apache Tomcat 8 from

Choose “zip” from Core on the Binary Distributions section.


2. Extract the archive to any directory

Configure Apache Tomcat 8 to enable CGI

1. Modify <SOMEWHERE>/apache-tomcat-8.0.14/conf/web.xml uncommented the whole cgi <servlet> tag and adding passShellEnvironment = true init-param.

2.  Modify <SOMEWHERE>/apache-tomcat-8.0.14/conf/context.xml by adding a privileged attribute and setting its value to true

3. Create a “cgi” directory under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF

4. Create a .cgi script under <SOMEWHERE>/apache-tomcat-8.0.14/webapps/ROOT/WEB-INF/cgi

5. Start Tomcat

6. Access http://localhost:8080/cgi-bin/test1.cgi


Got comments, or suggestions? Please visit our Facebook page!

You Might Also Like