Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/a26f9f83/public_html/articles/includes/config.php on line 159
Server Side Includes (SSI) with ASP > NetSparsh - Viral Content you Love & Share

Server Side Includes (SSI) with ASP


Server Side Includes (SSI) with ASP

People often have identical sections of code spread throughout many ASP pages, typically code at the top of the page (usually referred to as the header) and the lower part of the page (the footer). Similarly, you may have code that performs a certain set of instructions that you are repeating across multiple pages. Consider an example:-

<%
If foobar="yes" then
response.write "YES!"
Else
response.write "NOT YES!"
End if
%>

Ok, ok... it's simple, but imagine that you used this on multiple pages. What's wrong with this picture?

Well... you don't have to think about that long before realising that if you ever wanted to change something about that piece of code, you'd have your work cut out. you would have to change every page... everyone has done this at some stage and luckily most usually take the steps to learn a way around this problem.

If we could save our valuable chunk of code into a file and have that file accessed whenever we needed the code, then we no longer have a problem when it comes to changing things, as we simply update one file. Include files or Server Side Includes (SSI) as they are more commonly known are a powerful way to not only save time when it comes to maintaining and updating a site, but also increase efficiency and speed of that site too!

Ok, lets see how we use an include file... to start with we need to use one of two methods. The first one allows for including files relatively. By that I mean relative to the directory the ASP file that is using the include file resides. The second method includes files virtually. Including files virtually means that the path is taken from the root directory.

Consider that we are going to have a file (/main/somefile.asp) include another file (/includes/someinclude.asp).

To demonstrate, relative inclusion, look at this:-

<%
Response.Write "executing included code now"
%>
<!--#include file="../includes/someinclude.asp"-->
<%
Response.write "done executing included code"
%>

And here, we give an example of the other method, virtual inclusion:-

<%
Response.Write "executing included code now"
%>
<!--#include virtual="/includes/someinclude.asp"-->
<%
Response.write "done executing included code"
%>

Note the slight difference between the two methods. With virtual inclusion, you can move the file that calls upon the include file anywhere without affecting the outcome, because the path is always relative to the root. The same cannot be said however for relative inclusion. If you move a file that is using relative inclusion to a different directory, you'll most likely find the relative path is no longer correct.

From the examples above, you may also notice that both methods, when calling the include do so OUTSIDE of the ASP script block. This because #include declarations are not interpreted by ASP. Include files are included before a single line of ASP is processed which means the following WONT work:-

%lt;%
Page=request.form("page")
%>
<!--#include file="../includes/<%=page%>.asp"-->

We were attempting to perform a dynamic include and I would be the first to admit that the above would be very useful indeed if in fact it were possible. I do intend to cover a few methods that work around this set back but I know you will now be itching to get started right away on using include files to even worry about this, so I will cover it in a future article.

I hope that you have found the above informative and hope it inspires you all to write code that's more efficient and more easily maintained.

Rob Collyer, experienced with 20 years programming knowledge and site administrator of www.webforumz.com - Copyright 2003-2004

In The News:

This RSS feed URL is deprecated, please update. New URLs can be found in the footers at https://news.google.com/news

Android Authority (blog)

7 web development kits for less than the price of 1
Android Authority (blog)
That's the price that The Complete PHP & MySQL Web Development Bundle has been slashed to this week. This combination of seven online training kits and 44 hours of expert instruction is enough to take you from an absolute noob to web dev guru by the ...


Careers in Web Development
Telangana Today
In the last edition we have discussed about various technology stacks, what to learn and what is the career path. This article details about careers in web development, design & marketing. The word “Web” is one of the top 10 used words across the world ...


Learn Website Development Using Your GI Bill … In 14 Weeks!
ClearanceJobs (blog)
To learn full-stack web development in 14 weeks means the program is intense – up to 14-hour days, six days a week. An optional internship program extends the course to 32 weeks and gives the student more real-world coding experience which looks good ...


Customer Think

Why is WordPress the Best CMS for web Development?
Customer Think
Introduction. We know that all businesses need to have an online presence in order to survive in this competitive world. A professionally made website can help a business to increase its chances of becoming successful. There are a lot of website ...

and more »

Neowin

Pay What You Want or beat the average for this Full Stack Web Development Bundle
Neowin
Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can Pay What You Want for the Full Stack Web Development Bundle. The world's best developers are Full Stack developers. Here's 122+ hours of ...


mediabistro.com

Web Developer
mediabistro.com
The Web Developer will be responsible for front-end web development of The Arc's existing and new websites. He/she will play a project management role on any complex web development projects that require the support of outsourced designers and ...


TNW

Keep users in the heart of web development with this UI/UX Design training — and name your price
TNW
We all know how important site architecture and usability is to a website's eventual success or failure. While the actual mechanics of site building are usually front and center in web development, it's surprising how seldom a user's feelings about a ...


TechRadar

Best web development tools of 2018
TechRadar
Traditionally, when we think of web development, we picture some coder typing furiously on a keyboard into the wee hours of the night while slurping coffee, sitting in a dark basement next to the flashing LEDs and whirring hard drives of a stack of ...


Web Development Manager
Radio Today (Aust & NZ)
Digital Infrastructure & Development Manager. An extremely rare opportunity has become available with one of Australia's largest regional media companies, Grant Broadcasters. The Grant Broadcasters Digital Media Team are responsible for the delivery of ...


Fishbat Digital Marketing Agency Shares 5 Website Development Hacks That Will Increase Traffic
Markets Insider
LONG ISLAND, N.Y., July 13, 2018 /PRNewswire-iReach/ -- In an effort to help business owners increase website performance and revenue, digital marketing agency fishbat shares 5 website development hacks that will increase traffic. Having a solid ...

Google News

Top 5 Reasons to Track Your Website Traffic

#5 User Satisfaction: Learn what your visitors and site users... Read More

What Business Owners MUST Know BEFORE They Commit To Having A Web Site

Q1.Why would I need a web site? A1.- Improve my... Read More

Where?s Your Web Site?

This simple question can take on several different forms, but... Read More

How To Get Your Customers To Trust Your Website

Research reveals three important facts:1) The Internet is one of... Read More

How to Get Your Website In Front of Thousands of Customers At No Cost To You!

Dan Kennedy once said that if you can't make money... Read More

From Search to Sale

The Internet car buyer is an elusive animal. Trying to... Read More

Frequent Business Question: How Do You Start a Web Business?

Today it seems everyone is jumping on the entrepreneur bandwagon,... Read More

6 Steps To Your Own Website

A lot of people these days are interested in getting... Read More

Increase Your Affiliate Earnings with a Smart Webmaster Plan

Affiliate programs are a great way to earn an income... Read More

Get Your Business on the Web

I can't think of any business alive today that couldn't... Read More

Successful Web Development: 10 Key Elements

There are many elements that are key to successful web... Read More

The 5 Biggest Mistakes Almost All Web Designers Make

Huge Mistake #1: Creating a Website with Flash -- Did... Read More

10 Things You Should Be Monitoring On Your Website

Every business needs to know how it is doing. That's... Read More

But My Business Doesnt Need A Website!

Revenues are often lost because many business owners don't see... Read More

Website Conversion Rate: More Keywords Equals More Sales

Your website conversion rate should concern you. This simply refers... Read More

The Road to Better Results

A lot has changed in the way sites are optimized... Read More

KISS Your Website!

Many web developers today are starting to KISS their website,... Read More

HTML Editors 101 - Smaller Is Better

SiteSpinnerSiteSpinner is a user-friendly web site development tool that includes... Read More

Building a Great Intranet Taxonomy

While it may seem like a "quick and easy" task,... Read More

Developing A Website: 10 Tips For Getting Started

1. Be clear on your purpose.Building a website can be... Read More

How To Get Profits From Your 404 Page Not Found File

"'Page Not Found' on this Server. Check the URL and... Read More

Why Your Brick-and-Mortar Biz Needs A Website

The internet has taken over our lives with a vengeance,... Read More

How to Create a Professional Web Site in 24 Hours

While creating a Web site may seem like... Read More

What is The Google Toolbar?

No matter what browser you may want to use, you... Read More

WYSIWYG Versus Coding: HTML With A Purpose

After years of working with entrepreneurs who developed their first... Read More