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

AroundtheO

New Portland program focuses on coding and web development
AroundtheO
In an effort to meet regional demand for web developers, the UO will offer a new 24-week coding course in Portland starting this January. The University of Oregon Coding Boot Camp is a part-time program is geared toward adult learners and working ...

and more »

ZDNet

Cloudflare IPFS Gateway boosts decentralized website development
ZDNet
Cloudflare hopes the gateway will "serve as the platform for many new highly-reliable and security-enhanced web applications." The difference between traditional website content calls and IPFS comes down to the nature of queries and how online content ...
Cloudflare goes InterPlanetary - Introducing Cloudflare's IPFS Gateway - The Cloudflare BlogThe Cloudflare Blog

all 12 news articles »

KNWA

AR Girls Code Hosts Web Development Workshop
KNWA
FAYETTEVILLE, Ark. (KNWA) - AR Girls Code will host a web development session on Saturday for young women. Participants will learn how to build a website and will also be able to be a part of an HTML/CSS tutorial and a JavaScript or jQuery tutorial.


Mashable

Learn how to become a web developer with this $39 online training series
Mashable
If you're interested in a career in coding and developing web projects, you're going to need more than "a season of watching Silicon Valley" on your résumé. A solid foundation in technical skills is required as a minimum. But paying for several ...


Job: Web Developer – Alta Planning + Design
BikePortland.org
Websites may include web-map elements, and should be mobile-optimized, accessible, and localizable. Candidates should be committed to continual learning of new tools and methods; Alta will support ongoing training and professional development.


Senior Web Development Specialist
mediabistro.com
Illinois Public Media seeks a Senior Web Development Specialist for the WILL AM-FM-TV public broadcasting stations licensed to the University of Illinois at Urbana-Champaign. While other media organizations have only figured out that people want media ...


Android Authority (blog)

Learn the tricks of web development in 44 hours
Android Authority (blog)
That's right, for just $29 you can get the Complete PHP & MySQL Web Development Bundle this week. This combination of seven online training kits and 44 hours of expert instruction is enough to take you from absolute newbie to pro web developer by the ...


Interesting Engineering

You Can Become a Web Developer with This Interactive Coding Bootcamp
Interesting Engineering
It should go without saying that knowing how to code gives you a significant advantage when it comes to landing a lucrative position in a nearly endless number of tech subfields. But knowing just one or two programming languages and platforms is no ...
Teach yourself web development with this $39 online training seriesAndroidGuys (press release)

all 3 news articles »

Web Design Company, Ecommerce Website Development & SEO, Maximize Studio
Digital Journal
The one thing that sets us apart from most other web design firms is our commitment to quality and the fact that we do not offer clients templates but rather custom designs, customized to suit our client needs, requirements. New Jersey (PRUnderground) ...

and more »

Intro to Web Development
Miami Today
Ironhack Miami hosts its free into to web development workshop. 6:30-8:30 p.m. Ironhack, 120 SW Eighth St., Miami. Details: https://bit.ly/2MHbARK. + Google Calendar+ iCal Export. Details. Date: September 17; Time: 6:30 pm – 8:30 pm. Event Category: ...

Google News

Learn What 98% of Targeted Visitors Do On Your Website

Getting a Targeted Visitor to a website is a waste... Read More

Web accessibility for screen magnifier users

The needs of screen magnifier users are overlooked when implementing... Read More

How To Start Your Own Website

I'm one of those people that always wanted a website,... Read More

Using Psychology Easily on Your Website to Make More Sales!

Psychology is a long word which everyone thinks, "no, that's... Read More

What is SQL?

What is SQL? SQL stands for Structured Query Language and... Read More

5 Tips For A Better Website

Having an eye catching website is great, but are you... Read More

What YOU Should Know Before Getting A Web Site!

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

Selling Your Site: Outsource or Homemade?

To the starting internet entrepreneur, there is nothing more discouraging... Read More

What and How to choose the Right Keywords for Mega Traffic

Keywords in Search Engine Optimizing and Search Engine Marketing are... Read More

Website For The Company Store

If your company own one or more stores, you might... Read More

How to Promote Your Law Firm Website On the Internet for Maximum Profit

Making maximum profit from your law firm website is important,... Read More

Product Promoting: Getting The Response

When you publish a content site there are times when... Read More

Newsletter Management Using PHP w/o mySQL for Beginners

Let's begin by setting some limits. If you're like me,... Read More

HTML Editors 101 - Smaller Is Better

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

Web Content Strategy 101

Your content is what gets you in search engines, speaks... Read More

Planning Your Website for Success

Most people know they need a website in order to... Read More

6 Steps To Your Own Website

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

Developing A Website: 10 Tips For Getting Started

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

You Need a Website!

No matter the size of your business, having a web... 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

2 Key Ways to Make Your Site a Success

If one more business owner tells me their website sucks... Read More

Benefits Of An Accessible Website: Part 1 - Increase In Reach

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

Why You Really Need Your Own Web Page In-order To Make Online Business!

How many Web Sites did you stumble over telling you... Read More

The Internet Road Map

1) Data CaptureOne easy way to collect e-mail addresses and... Read More

Websites: You Get What You Pay For!

So you finally decided to invest in a web presence... Read More