August 24, 201115 yr 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.
August 24, 201115 yr 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" -->
August 25, 201115 yr 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 August 25, 201115 yr by DaveyL
August 27, 201115 yr 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.
August 28, 201115 yr 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.
August 30, 201115 yr 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