Web-development informational articles

Head waiter side includes (ssi) with asp - web-development

 

Server Side Includes (SSI) with ASP

People often have duplicate sections of code allot all through 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 a number of set of directives that you are repeating crosswise compound pages. Bear in mind an example:-

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

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

Well. . . you don't have to think about that long ahead of realising that if you ever required to alter amazing about that piece of code, you'd have your work cut out. you would have to alteration every page. . . all has done this at some stage and luckily most customarily take the steps to learn a way about this problem.

If we could save our constructive chunk of code into a file and have that file accessed every time we considered necessary the code, then we no longer have a conundrum when it comes to altering things, as we easily fill in one file. Bring in files or Ma?tre d' Side Includes (SSI) as they are more regularly known are a brawny way to not only save time when it comes to maintaining and updating a site, but also add to efficiency and speed of that site too!

Ok, lets see how we use an bring in file. . . to start with we need to use one of two methods. The first one allows for plus files relatively. By that I mean family member to the address list the ASP file that is using the consist of file resides. The agree with logic includes files virtually. Plus files effectively means that the path is taken from the root directory.

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

To demonstrate, next of kin inclusion, look at this:-

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

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

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

Note the affront differentiation concerning the two methods. With virtual inclusion, you can move the file that calls upon the bring in file someplace devoid of heartwarming the outcome, as the path is constantly comparative to the root. The same cannot be said in spite of this for qualified inclusion. If you move a file that is using qualified inclusion to a assorted directory, you'll most possible find the qualified path is no longer correct.

From the examples above, you may also become aware of that both methods, when business the comprise do so Exterior of the ASP draft block. This for the reason that #include declarations are not interpreted by ASP. Consist of files are incorporated ahead of a free line of ASP is processed which means the next WONT work:-

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

We were attempting to act upon a dynamic comprise and I would be the first to admit that the above would be very beneficial as a matter of fact if in fact it were possible. I do anticipate to cover a few methods that work about this set back but I know you will now be impatient to get on track right away on using comprise files to even worry about this, so I will cover it in a coming article.

I hope that you have found the above informative and hope it inspires you all to write code that's more competent and more by a long way maintained.

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


MORE RESOURCES:



The Future of Web Development  Business 2 Community




















Web Developer - OneSpan  Built In Chicago
















School board highlights  Oliver Chronicle





























































Developed by:
home | site map
goldenarticles.net © 2019