Server Side Includes

I would like to create a text file that has some content that needs to be displayed.  I want to use some kind of server side include to display that file on a web page.  How can I do this?  Does the file have to use HTML tags and the like?  I would be interested in both options displaying files with html code in them and files without.  Is this possible.

Thanks
gl
gretchenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
That should be pretty easy on most web servers:

<HTML>
<BODY>
Here is some stuff.
<!--#INCLUDE FILE="myfile.txt"-->
more stuff here
</body>
</html>


"myfile.txt" may or may not include HTML code.
0
gretchenAuthor Commented:
This is what I have and it is not working.  I am using PWS from MS from Win 98.  The SSI text file contains the line this is a test.

<html>

<head>
<title>This is a ssi include test</title>
</head>

<body>
This is in the middle of the page
<!--#INCLUDE file="D:\database\ssi.txt"-->
</body>

</html>
0
kpu8Commented:
try this -
<html>

<head>
<title>This is a ssi include test</title>
</head>

<body>
This is in the middle of the page
<!--#INCLUDE file="file:\\\D:database\ssi.txt"-->
</body>

</html>
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

kpu8Commented:
Also - you may want to move the ssi above the body tag I think?

0
Jan LouwerensSoftware EngineerCommented:
Plus you are using the backslash character in a string, which usually escapes the next character (is this true in html strings also?)
If so, try:
<!--#INCLUDE file="D:\\database\\ssi.txt"-->

or as kpu8 suggests:
<!--#INCLUDE file="file:\\\\D:\\database\\ssi.txt"-->
0
kidziCommented:
Gretchen,

<html>

<head>
<title>This is a ssi include test</title>
</head>

<body>
This is in the middle of the page
<!--#INCLUDE file="D:\database\ssi.txt"-->
</body>

</html>

Should work, as given above, however make sure the file this is saved in has a .shtml extension, or else server side includes will NOT work.  If you use an .asp extension, then it should also work alright with PWS.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
knightEknightCommented:
I don't think you can use a filesystem path like "D:\database\"  ... Instead I think you will have to put ssi.txt in a directory accessible from the web root.  It will work just fine in the same directory as the HTML page, or in a directory relative to the web root.  For example, if the file resided in C:\InetPub\wwwroot\database\ssi.txt  then the following would work:
 <!--#INCLUDE file="/database/ssi.txt"-->

0
gretchenAuthor Commented:
Thanks, my problem ended up being I needed to rename the page to have an ASP extension.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.