Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to use .shtml file

Featured Replies

Hello All,

 

This is my first post on this site. I am experienced in Mainframe technology and new to Webdesign.

 

I would like to know how to create .shtml file to include files like header and footer in the html page. I am using Apache Tomcat 6 server.

 

I have gone thru some websites and tried changing Tomcat's Web.xml file to remove the comments so as to enable the SSI Servlet and its mapping.

 

Please find below the index.shtml.

 

<body>

 

<!--#include file="Header.html" -->

 

<h1> Inside Home.shtml file !!!! </h1>

 

<!--#include file="Footer.html" -->

 

</body>

 

In this code, contents of included files are not displayed. However this .shtml content (<h1>) is getting displayed.

 

Please let me know how to use/create .shtml file.

 

 

Thanks,

Srivathsan.

Try using virtual instead of file

 

<!--#include virtual="Header.html" -->

 

You can also verify if SSI is working by echoing out an apache variable

 

Your IP address is <!--#echo var="REMOTE_ADDR" -->

We use shtml pages and your include code looks fine. The 'include file' allows you to link to an htm / html page in the same directory or sub directory.

 

Is it looking in the right path for the 'header' and 'footer' html files?

 

By the way we usually only use the virtual argument if the file is located in a position requiring an address starting at the server root, for example

 

<!--#include virtual="/pls/portal/PSCM_Web.metadataSearch?p_contentType=46&p_resultsInList=Y&p_orderBy=content/eventDate&p_limitResults=6&p_forceDisplayPage=events.shtml"-->

 

Final thing to look at is that the called for file does not have a doc type specified - it simply needs the content as your doc tyoe should be defined on your index.shtml page already.

 

These are just quick thoughts anyway, if your all sorted with this stuff already am afraid I can't think of any other reason.

Edited by DaveyL

  • Author

Hi,

 

Thanks for all your suggestions.

 

I tried using "virtual=" instead of "file=" attribute and <!--#echo var="REMOTE_ADDR" -->.

 

Remote Address is not getting displayed.

 

Is there any other configuration that i need to do to enable SSI in Tomcat other than Web.xml changes?

 

 

Thanks,

Sri.

I use tomcat at work but we dont use SSI we use jsp includes, e.g index.jsp

 

<body>

<%@ include file="Header.html" %>

<h1> Inside Home.shtml file !!!! </h1>

<%@ include file="Footer.html" %>

</body>

 

I looked in the tomcat docs, all it says is rename $CATALINA_BASE/server/lib/servlets-ssi.renametojar to $CATALINA_BASE/server/lib/servlets-ssi.jar then uncomment in your xml config...

 

   <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>

 

Restart tomcat after editing.

  • Author

Hi All,

 

.shtml is working fine now. I have copied "ssi servlet and its mapping" coding from Tomcat's Web.xml into my application's Web.xml file also copied Context.xml. Also removed comments from servlet ssi in Tomcat's Web.xml.

 

Since I am using Tomcat 6, I didnt require "servlets-ssi.renametojar" changes.

 

I heard that Html, CSS, Javascript have to be used in Website creation (Simple College Website) for some reason. So I din't use JSP.

 

Thanks,

Sri.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.