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:


TNW

5 website development trends that rocked 2017
TNW
Regardless of the technological dynamics, a good website should be easy and affordable for use by the web owner or their clients, a convenience which should be prioritized by web developers. Hence, the following website development trends made to the ...


Vertical Measures (blog)

Why Your Web Development Project Needs an SEO Agency
Vertical Measures (blog)
It may be that there's so much going on in the website development process that SEO becomes, “We'll get to it later.” Or, it may be that your web development agency just doesn't specialize in SEO, even if they say they do. With the constant evolvement ...

and more »

Daily Free Press

Girls Who Code teaches web development, encourage women participation in field
Daily Free Press
From programming scientific software to redoing a portfolio website, coding has become one of the most in-demand skills in many industries. Girls Who Code BU hosted their first “Introduction to Web Development” workshop to make learning about coding ...


SDTimes.com

Mozilla leads project to consolidate web development documentation across browsers
SDTimes.com
Mozilla is teaming up with Microsoft, Google, W3C, Samsung and other industry leaders as part of a joint effort to “make web development a little easier” by bringing documentation for multiple browsers to their MDN Web Docs educational platform. The ...
MDN Web Docs to Become Single Source for Cross-Browser Development DocumentationHTML Goodies

all 4 news articles »

Entrepreneur

Learn About Wireframes Before Hiring a Web Developer
Entrepreneur
When it comes to web development, that means two things. First, read through Clients From Hell and strive to never be "that guy." Second, be ready to present your web developer with a wireframe. When I say the word wireframe, what do you picture? If ...


TNW

How visual web development can change the landscape of web design
TNW
Could it be artificial intelligence driving web design? Maybe, but that is still a long way off. In the interim, we should look more at things like visual development. You see, one issue with many web design/development projects is the disconnect that ...

and more »

Technabob (blog)

Master the Art of Web Development for Only $59.99
Technabob (blog)
Become a pro web developer with a lifetime of guidance from OSTraining Developer Bootcamp. You'll get access to thousands of video tutorials for life, and pay only $59.99 (USD). That's 97% down from the list price of $2000. zoom in. With instruction ...


TNW

Get all the web development training you'd ever want or need — now for an extra $10 off
TNW
Whether you're just trying to find out about topics that interest you or you're seeking information specifically to jumpstart your professional career, there's always a good reason to expand your horizons. Learn anything about web development you want ...


Business.com

How to Hire a Great Web Developer
Business.com
A good web developer can be the difference between having a great online presence and a counterintuitive, ugly website. But finding the right person for your needs can be harder than you might think. That's especially true for business owners who aren ...


PocketNow (press release) (blog)

3000+ web development videos — currently 97% off
PocketNow (press release) (blog)
Topics covered range from programming languages (Javascript, HTML, and more) to WordPress and WooCommerce. The OSTraining Developer Course is your one-stop shop to launching your own website. The subscription is actually 97% off currently.

Google News

Improve Web Sales Figures Forever And Ever Amen!

"How do I improve web site sales figures?" The CEO... Read More

How to Draw Icons or Images on a Mapserver Generated Map

In this example I have used the map of the... Read More

My Yahoo Search - Beyond Bookmarks

Yahoo has long offered email, an online calendar, notes, bookmarks,... Read More

Why a CSS Website Layout Will Make You Money

Although CSS layouts have been around for years, they haven't... Read More

Websites for Writers ? Why You Need One and How to Get Started Today

It may seem like the publishing industry's equivalent of Beanie... Read More

But My Business Doesnt Need A Website!

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

How Worldly is Your World Wide Web?

The growth in Internet usage around the world is astounding... Read More

From Search to Sale

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

Should You Design Your Own Website?

If you're anything like most small business owners, you probably... Read More

Marketing Your Business Online

As a business you can't afford to ignore the Internet... Read More

Three Way Linking - Webmaster Strategy

Three way linking and concerns.For many years SEO experts were... Read More

PHP Redirect

A PHP Redirect automatically transfers a web user from one... Read More

Free Websites & Why You Should Avoid Them

It amazes me how many people try to build serious... Read More

The Dos and Donts of Launching a Small Business Website

Launching a new small business website is often a long... Read More

Now You Have a Web Site - Have You Ever Heard of Accessibility?

An accessible Web site is easily approached, easily understood, and... Read More

How to Get a Better Web Site ROI

Better Web Site ROIHow to increase your business profitability by... Read More

Building Websites with Directory Generator

Directory Generator, a product from Armand Morin and Marc Quarles,... Read More

PIM Team Case Study: Creating Text Effects With PHP and GD

See how you can create graphic effects on text with... Read More

Does Your Business Really Need A Website?

Website, website, website, everyone says you need one. But do... Read More

What YOU Should Know Before Getting A Web Site!

Everyday thousands of new businesses make the leap and take... Read More

Improve Conversion Rates ? Effective Content

Your site is fast and getting traffic, but conversion rates... Read More

Web Development Processes and Technical Environments

The process of Web application development is critical to the... Read More

Building eCommerce Websites that Work - Part 2

Succeeding with an eCommerce website is a dream for many... Read More

If Its Done Its Done for: Make Your Website Part of Your Business before You Build

Web sites are an Ongoing Part of Business.All too many... Read More

9 Keys to an Effective Website

Many small companies choose not to invest in a professionally... Read More