Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Running SSI (Server Side Include) scripts in Apache Tomcat

Server Side Includes provide the web user with a handful of facilities that can be included in their HTML pages, to be parsed out / completed by the server. For example, the date and time can be included in a web page using an SSI.

Both httpd and Tomcat can support SSIs, provided that the server is configured to provide the support; where the configuration IS done, it's usual for an extension .sht or .shtml to be used.

SAMPLE SSI SCRIPT

Here's a sample "ssi" script that you might want to install on your Tomcat server:

<head><title>Linux, Apache httpd, Tomcat, MySQL, Java</title></head>
<body><h1>Linux, Apache httpd, Tomcat, MySQL and Java</h1>
This is part of a sample web application that tests Tomcat deployment.
<hr>
Server side include - date is <!--#echo var="DATE_LOCAL" -->
<hr>
Page written by Well House Consultants Ltd, +44 (0) 1225 708225<br>
web <a href=http://www.wellho.net>http://www.wellho.net</a><br>
email <a href=mailto:info@wellho.net>info@wellho.net</a><br>
</body>

CONFIGURING TOMCAT TO SUPPORT SSI

Although SSI support is shipped with the standard Tomcat load, the vital information that you'll need is commented out in the web.xml file and you need to uncomment the following to add in the support:

    <servlet>
        <servlet-name>ssi</servlet-name>
        <servlet-class>
          org.apache.catalina.ssi.SSIServlet
        </servlet-class>
        <init-param>
          <param-name>buffered</param-name>
          <param-value>1</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>expires</param-name>
          <param-value>666</param-value>
        </init-param>
        <init-param>
          <param-name>isVirtualWebappRelative</param-name>
          <param-value>0</param-value>
        </init-param>
        <load-on-startup>4</load-on-startup>
    </servlet>

and also you need to map appropriate URLs on to that support:

    <servlet-mapping>
        <servlet-name>ssi</servlet-name>
        <url-pattern>*.shtml</url-pattern>
    </servlet-mapping>

There's one further change to make - the SSI API is provided in a .jar file that you need to rename in the /usr/local/tomcat/server/lib (or similarly named) directory:

mv servlets-ssi.renametojar servlets-ssi.jar



See also Deploying applications under httpd and Tomcat

Please note that articles in this section of our web site were current and correct to the best of our ability when published, but by the nature of our business may go out of date quite quickly. The quoting of a price, contract term or any other information in this area of our website is NOT an offer to supply now on those terms - please check back via our main web site

Related Material

Web Application Deployment - Tomcat - Configuring Web Applications
  [3996] Tips on Tomcat - moving applications around - (2013-02-05)
  [3044] Changing a Servlet - more that just editing and compiling - (2010-11-12)
  [2088] Changing the 404 - file not found - page in Tomcat - (2009-03-18)
  [1909] javax.servlet cannot be resolved - how to solve - (2008-11-26)
  [1564] Default file (MiMe types) for Apache httpd and Apache Tomcat - (2008-03-04)
  [1552] Extra public classes in deploying Apache httpd and Tomcat - (2008-02-24)
  [1192] What are WEB-INF and META-INF directories? - (2007-05-18)
  [1082] Straight from the .jar - (2007-02-16)
  [1074] Java beans and classes, .war and .jar files - (2007-02-10)
  [1006] Apache httpd and Apache Tomcat together tips - (2006-12-24)
  [754] tar, jar, war, ear, sar files - (2006-06-10)
  [479] New servlet from old - (2005-10-28)
  [465] Changing Tomcat's web.xml and reloading a web application - (2005-10-15)

Web Application Deployment - Tomcat -Sourcing, Installing and Initial Testing
  [3819] Packing a tar, jar or war file - best practise - (2012-07-26)
  [2088] Changing the 404 - file not found - page in Tomcat - (2009-03-18)
  [1550] Java (JSP and Servlet examples) live on our server - (2008-02-23)
  [1049] Java 6, Apache Tomcat 6. - (2007-01-21)
  [837] Tomcat - Shutdown port - (2006-08-18)

Web and Intranet - Executable Content
  [2628] An example of an injection attack using Javascript - (2010-02-08)
  [1814] Javascript/HTML example, dynamic server monitor - (2008-09-28)
  [1813] Ajax - going Asyncronous and what it means - (2008-09-28)
  [1812] Starting Ajax - easy example of browser calling up server data - (2008-09-27)

resource index - Java
Solutions centre home page

You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum.

At Well House Consultants, we provide training courses on subjects such as Ruby, Lua, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/solutions/java-run ... omcat.html • PAGE BUILT: Wed Mar 28 07:47:11 2012 • BUILD SYSTEM: wizard