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

Web Development from Profit by Outsourcing, a Cost-Effective Way to Build Successful Online Business
NB Herard
Noida, Uttar Pardesh — 12/11/2017 — #1 Web Design & Development Company in India, Profit by Outsourcing offers first-class web development services that will surely prove to be beneficial for entrepreneurs in cost-effectively building a successful ...

and more »

Forbes

Eight Web Development Trends Coming In 2018 - Forbes
Forbes
Look to the future now for ideas and inspiration so that you can stay ahead of the competition.

and more »

The Augusta Chronicle

Bootcamp to teach code, web development | The Augusta Chronicle
The Augusta Chronicle
An Augusta tech-business cooperative is taking applications for winter semester classes in coding and web development. An information session for the third round of Code Bootcamp will be at theClubhou.se, 540 Telfair St., from 6-7 p.m. Nov. 28. The ...

and more »

SiteLock president shares hard truth on secure web development
TechTarget
In this Q&A, Neill Feather, president of SiteLock, a business website security provider, delves into this issue. He explains that while news surrounding security issues may suggest that large enterprises are the most at risk, it's actually small ...


TNW

Mozilla just launched an augmented reality app
TNW
The app isn't merely a demonstration of interesting mixed reality experiences created with web technologies (although it does this very well.) Rather, it serves to advocate for Mozilla's proposed WebXR standard, which is yet to take root in the web ...

and more »

GCN.com

Accessibility awareness remains low as deadline approaches
GCN.com
Beginning Jan. 18, 2018, government agencies across the U.S. will be required by law to make their websites accessible to the more than 60 million Americans with visual, hearing or other disabilities. Yet more than 87 percent of 430+ local government ...


City panel approves increase in towing fees
Terre Haute Tribune Star
The abatement is pending before the Terre Haute City Council. • Approved a $16,500 agreement with Innovative Integration of Indianapolis for 100 hours of web development work. The agreement involves work for which city employees lack the necessary ...


Freelance Sr. Web Developer
Built In Chicago
Enjoy building great things with great people? We're looking for enthusiastic individuals to help our tech team in problem solving, building, designing and architecting advanced technical solutions for our clients! One North is structured in an open ...


The Guardian

Island web development start-up Forestry.io gets federal funding ...
The Guardian
CHARLOTTETOWN, P.E.I. – A website development start-up in Prince Edward Island has received nearly a quarter of a million dollars to help bring its technology to market. Charlottetown-based Forestry.io created an easy-to-use website.

and more »

Rocky Mountain Collegian

CSU student creates web development company
Rocky Mountain Collegian
Jonathan Emig, a junior studying engineering science, started Flux Teck, a web developing company, that designs websites or mobile applications for small or large businesses. His company got its first recognition after Emig's freshman year of college ...

Google News

What is Blogger.com?

In the late 1990's three San Francisco based web developers... Read More

Beware the Software Siren

I've heard several prominent web marketers mention in their classes... Read More

Stop Losing Precious Web Site Traffic to the Dreaded World Wide Web Black Hole

You work hard to build traffic to your web page.... Read More

Make Your Own Website - General Website Design Tips

Wow, we`ve already taken a domain and chosen a web... Read More

What YOU Should Know Before Getting A Web Site!

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

Website Sales: 10 Reasons Why People Dont Buy From You

You've put up a website to promote a product or... Read More

Linking Out is Good

Many websites I come across don't have a single link... Read More

Traffic for Webmasters

"If you build it, they will come"; is an age... Read More

3 Ways To Increase Your Websites Conversion rate

Everywhere you look these days, people are telling you that... Read More

Why Should Your Business Go O.N.L.I.N.E.

Optimize your time. How much time each day must you... Read More

Guide to Internet Business - Website Setup

After planning the design and content of your website, it's... Read More

Making the Most of Your Website: Start with the Basics

One of my most salient memories from when I sold... Read More

Writing Effective ALT Text For Images

Anyone who knows anything about web accessibility knows that images... Read More

Do You Need a Web Database?

Does My Web Site Require A Web Database?If your web... Read More

Earn On Offshore Web Design and Development

If you have some experience in web site design and... Read More

Top 5 Reasons to Track Your Website Traffic

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

Benefits Of An Accessible Website: Part 2 - The Business Case

The DDA (Disability Discrimination Act) states that service providers must... Read More

Free Isnt Always Good - 5 Reasons Why You Need Your Own Website

Often time I've browsed sites and seen the same thing... Read More

3 Essential Tools Every Website Designer and Marketer Needs

Appealing to others is really important when you have a... Read More

Increase Your Affiliate Earnings with a Smart Webmaster Plan

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

HTML Editors 101 - Smaller Is Better

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

The Two Most Common Mistakes That Scare Away Web Visitors

Can you imagine the hypocrisy of spending thousands of dollars,... Read More

Preventing Repeat Form Submission Using PHP Sessions

We've all seen those messages on some websites warning not... Read More

Three Way Linking - Webmaster Strategy

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

Freelance Programming is Easy to Manage

There are several reverse bid freelance sites out there. Beyond... Read More