Solved

INCLUDE File Problem

Posted on 2003-11-29
14
121,519 Views
Last Modified: 2013-11-18
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
Comment
Question by:bparmelee
  • 5
  • 4
  • 2
  • +3
14 Comments
 

Author Comment

by:bparmelee
ID: 9842979
P.S.  Both files are in the same (root) directory.
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9842996
@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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 9843092
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9843153
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9843265
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9843411
@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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9843496
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:bparmelee
ID: 9843515
THe shtml extension did the trick.  Thanks!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9843550
Glad we could help. Thanks for the A. :^)

Cd&
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9843749
@COBOLdinosaur:  Where do I find those settings?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9843802
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
 

Expert Comment

by:co2tux2600
ID: 11928420
I'm lazy..use php.  

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

:P
0
 

Expert Comment

by:DirkManuel
ID: 12045730
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
 

Expert Comment

by:jimmysays
ID: 12662453
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Website Home page blank 4 26
Library to convert HTML to PDF. 8 45
HTML button disabled 11 36
Stupid git question 2 21
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now