This is a discussion on "ASP Include Files (SSI or Server Side Includes)" within the Classic ASP section. This forum, and the thread "ASP Include Files (SSI or Server Side Includes) are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
ASP Include Files (SSI or Server Side Includes)
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
ASP Include Files (SSI or Server Side Includes)
ASP Include Files (SSI or Server Side Includes)
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 this really basic example:-
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:-
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:-
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. |
|
|
|
#2
|
||||
|
||||
|
Very well said, thank you for the great info...
|
|
#3
|
|||
|
|||
|
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote"><%
Response.Write "executing included code now" %> <% Response.write "done executing included code" %><hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"> Just so you're aware, did you know that the include will actually be done BEFORE that Response.Write is executed. It doesn't come across the response.write, write it, then include the file. Includes are ALWAYS processed first. |
|
#4
|
||||
|
||||
|
Hi ....
Yes I know that... as I said up above somewhere... <blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Include files are included before a single line of ASP is processed<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote"> Maybe I used a bad example.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
![]() |
| Tags |
| asp, include, files, ssi, server, side, includes |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java server side technologies | asim | Webforumz Cafe | 0 | Jun 20th, 2007 07:47 |
| Trouble with Server Side Includes | BGarner | Classic ASP | 3 | Jan 20th, 2007 17:16 |
| Server side executables | Donny Bahama | PHP Forum | 4 | Dec 30th, 2006 17:59 |
| Client-Side VS Server Side Scripting | redev2006 | JavaScript Forum | 1 | Jul 30th, 2005 19:30 |
| do server side includes affect performance? | spinal007 | Classic ASP | 13 | May 5th, 2004 12:34 |