[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 121526
  • Last Modified:

INCLUDE File Problem

I cannot get the INCLUDE function to work.  What am I doing wrong?  Thanks!

Here's the main file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
   <body>
      <p>In main HTML</p>
<!--#include file="z.html"-->
<!--#include virtual="z.html"-->
   </body>
</html>

Here's z.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
   <body>
      <p>In Footer</p>
   </body>
</html>

Results when I call the main file:
            In main HTML

(The "In Footer" words do not appear.)
0
bparmelee
Asked:
bparmelee
  • 5
  • 4
  • 2
  • +3
1 Solution
 
bparmeleeAuthor Commented:
P.S.  Both files are in the same (root) directory.
0
 
DexstarCommented:
@bparmelee:

> I cannot get the INCLUDE function to work.  What am I doing wrong?  Thanks!

You can't do that with HTML.  The syntax you are using is for ASP code, which only work with specific web server software.  If you are using IIS for your web server, then try renaming your main file to have a ".asp" extension.  Then it should work.  If you aren't using IIS, then you can't do what you're trying to do the way you're trying to do it.

Hope That Helps,
Dex*
0
 
COBOLdinosaurCommented:
Dexstar,

What are you talking about.  That is not ASP syntax.  

There are likely one of two (or possible both problems).

1. The server must be configured to recognize and support includes.
2.  If it is configured for includes, it must also have the extension configured.  Normally .inc, or .shtml are used but virtually anything including html can be configuted.

An good source for SSI related problems:

http://bignosebird.com/ssi.shtml

Cd&
 
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DexstarCommented:
What I meant was that the syntax of
    <!--#include file="z.html"-->

Has to be supported by the server for it to work, and won't just work with any web server.  It isn't ASP syntax perse.  I misspoke.  But, if you are on IIS, it does need to be an active server page (with the .ASP extension) for the server to process the SSI directives.

Dex*
0
 
COBOLdinosaurCommented:
ASP can process the directive, but you do not have to use ASP.  the includes will work in IIS for static HTML pages by mapping the extensions like .inc into Ssinc.dll I believe; all the SSI directives support by Microsoft work.  In an ASP page the only SSI directive that works is the include itsef.

Cd&
 
0
 
DexstarCommented:
@COBOLdinosaur:

Okay, I just tested this on IIS 5.  Maybe a new version is different, but here is what I found.  I took this file these files (IncTest.htm and Inc.htm):
---
IncTest.htm
---
<html>
<head>
<title>Inc Test</title>
</head>
<body>
<!-- #include file="inc.htm"-->
</body>
</html>
---
Inc.Htm
---
<B>Inc Test!!</B>
---

When I requested "IncTest.htm" with my browser, I got a blank page.  When I looked at the sourc, it showed the <#include> command in there.  Then I renamed the file "IncTest.asp", and requested that with my browser, and the file got included.

You have to invoke the scripting engine to get the server side includes to work.  By default, that means usings the .ASP suffix on your files.  (The suffix on the included file doesn't matter at all).  However, you can configure your web server to invoke the engine for .htm files too, but then you end up running the scripting engine on pages that don't contain any script, which is wasteful..

Dex*
0
 
COBOLdinosaurCommented:
It is not working for you without asp, because you have not configured Ssinc.dll to handle the includes with htm extensions.  IIS gets delivered with those kind of includes turned off and you have to user the manager interface to specifically configure the dll.

However given the poor performance of IIS on includes, you are better not to use them at all in IIs environments because it is more efficient to use client side scripting to generate shared code.

Cd&
0
 
bparmeleeAuthor Commented:
THe shtml extension did the trick.  Thanks!
0
 
COBOLdinosaurCommented:
Glad we could help. Thanks for the A. :^)

Cd&
0
 
DexstarCommented:
@COBOLdinosaur:  Where do I find those settings?
0
 
COBOLdinosaurCommented:
You can start here I guess:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/htm/ref_ssi_ssiref.asp

I hate usng the MSDN site, because they are always trying to mess with the browser, but try searching MSDN with Ssinc.dll as the argument.  That should give you some of the hype that MS likes to call tech documentation.

Cd&
0
 
co2tux2600Commented:
I'm lazy..use php.  

<?php include "z.html"; ?>

:P
0
 
DirkManuelCommented:
I'm new to PHP but I came here looking for the same question.  Now if you use PHP and include the z.html file, am I right in assuming that the z.html file should only contain HTML that is VALID AT THE POINT IT IS INCLUDED?  (i.e. you'd need to strip out the DOCTYPE, HTML and BODY tags?
0
 
jimmysaysCommented:
You may have to go into the Internet Service Manager and make sure the server side include dll has been associated with the extension you desire. To do that:

1.     Start the Internet Service Manager
2.     Click on the Default Website directory
3.     Right click and select Properties
4.     Select the Home Directory tab
5.     Under Application Settings, click on Configuration
6.     Make sure the .html extension is listed as associated with
c:\WINNT\System32\inetsrv\ssinc.dll; if it is not, then:
7.     To associate .html with the ssinc.dll, click the Add button
8.     Browse to c:\WINNT\System32\inetsrv\ssinc.dll in the executable field
9.     Enter .html (with the dot) into the Extension field
10.     Leave the Method exclusion field blank; leave Script engine checked and Check that file exists unchecked
11.     Click OK twice
12.     In the main Properties window, click Apply
13.     SSI should now be enabled for .html files
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now