entimp
06-16-2003, 11:30 PM
Intro (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-25590.html) - Pt 2 - Pt3 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-3-the-code-for-our-example-25644.html) - Pt4 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-4-save-the-code-30534.html) - Pt5 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-5-yay-it-is-all-over-30535.html)
So what is a server side include?
A server side include is a way of requesting a given piece of information from your server and including it in the displayed web document. The information can be anything you want it to be. Plain text, markup language, scripts etc...
The page we are writing has lots of repeated areas of code and it wouldn't make sense to write it out time and time again if we could avoid it. For now, Biology for Newbies only has one area that has unrepeated/unique code and that is the content section.
Logically we should try and break down the repeatable sections of code into sensible catogories. Biology for newbies can be broken down into these: Header
Navigation content
Code for center of table
Content
FooterAll of the above sections are repeatable sections of code other than the content section.
Given that I had all these files pre-created I could publish a web page in seconds bar the content. The code you would write would look something like this:<!--#include file = "includes/header.asp" -->
<!--#include file = "includes/nav.asp" -->
<!--#include file = "includes/table.asp" -->
<!--#include file = "includes/content_xx.asp" -->
<!--#include file = "includes/footer.asp" -->Believe it or not that code would display a full and valid web page providing you have all the includes pre-written.
One of the first things you will notice is the extensions to the includes. You could use any of 3 extensions for SSI, being *.txt, *.inc and *.asp. I suggest you only use the *.asp extension and will good enough to tell you why.
To understand why, you need to know how a SSI is served up. This is going to be extremely basic in description. To do this I will compare an ASP page with a HTML page.
A fairly basic web page written in HTML can be described as static file... when it is requested the HTML is sent you as it is and your browser defines how it is displayed on the screen. (for Peg) Once the browser has the code only then does it start to get the images. Images are not sent automatically with HTML file requests. It is also the same of HTML rendered via ASP...
The ASP server looks at the includes first, builds the HTML from all the seperate include files, sends it to your browser peiced togather and the browser then requests the images.
An ASP page (Active Server Page) is very different. Any page that runs ASP must have an extionsion of *.asp rather than *.htm. The include files will also be called *.asp (or *.inc or *.txt). For this tutorial I am going to suggest you use the *.asp extension and not the *.inc or *.txt ones. You will find it a little safer to use the *.asp extension due to the way a server responds to files with *.asp. This boils down to a file called ASP.DLL... suffice to say I wont explain anymore other than that you for simple includes you don't need to know anymore.
By giving the document an ASP extension you change the way a server deals with it. When you request an ASP file the server doesnt send it to you but has a read of it first. It needs to read it first to understand what must be done to , where all the includes can be found and only then put the front end code together before sending it to you.
With our example of SSI's you are telling the server to act like a wharehouse. In essence it reads the code and gets the shopping list together... one of these, two of them and a few of these and then follows instructions to put it together. Only then does it send it to you in the correct order. When you view the source you will not see the includes but the code that it put together like a jigsaw from the invidual includes.
Thus if you give your documents an extension of HTM or HTML the server would not know that it needs to read it first and then act on what it discovers. This doesn't mean that you can't write a normal HTML file and call it ASP. The server will still read it and discover that it has nothing to act on and just serve all the HTML to the browser. This should point out to you that no matter what ever is in your individaul ASP includes your browser still understands HTML and not ASP. ASP is not a language but a way of serving the language. So remember what ever pieces of the jigsaw you use they must end up as valid HTML when they reach the users browser.
Ok I think that is enough for now I will add the next step tomorrow. I will write up the code and show how it can be placed in a structured directory for logical usage and intelligent management of repeatable pieces of your web page. Then finally we will put it all together.
If you have any questions or comments please feel free to add them. It's 4am so go easy on me ;)
I hope that made some sense to someone out there.
Updated edit for Pegs questions... hope they make more sense now.
Intro (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-25590.html) - Pt 2 - Pt3 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-3-the-code-for-our-example-25644.html) - Pt4 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-4-save-the-code-30534.html) - Pt5 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-5-yay-it-is-all-over-30535.html)
So what is a server side include?
A server side include is a way of requesting a given piece of information from your server and including it in the displayed web document. The information can be anything you want it to be. Plain text, markup language, scripts etc...
The page we are writing has lots of repeated areas of code and it wouldn't make sense to write it out time and time again if we could avoid it. For now, Biology for Newbies only has one area that has unrepeated/unique code and that is the content section.
Logically we should try and break down the repeatable sections of code into sensible catogories. Biology for newbies can be broken down into these: Header
Navigation content
Code for center of table
Content
FooterAll of the above sections are repeatable sections of code other than the content section.
Given that I had all these files pre-created I could publish a web page in seconds bar the content. The code you would write would look something like this:<!--#include file = "includes/header.asp" -->
<!--#include file = "includes/nav.asp" -->
<!--#include file = "includes/table.asp" -->
<!--#include file = "includes/content_xx.asp" -->
<!--#include file = "includes/footer.asp" -->Believe it or not that code would display a full and valid web page providing you have all the includes pre-written.
One of the first things you will notice is the extensions to the includes. You could use any of 3 extensions for SSI, being *.txt, *.inc and *.asp. I suggest you only use the *.asp extension and will good enough to tell you why.
To understand why, you need to know how a SSI is served up. This is going to be extremely basic in description. To do this I will compare an ASP page with a HTML page.
A fairly basic web page written in HTML can be described as static file... when it is requested the HTML is sent you as it is and your browser defines how it is displayed on the screen. (for Peg) Once the browser has the code only then does it start to get the images. Images are not sent automatically with HTML file requests. It is also the same of HTML rendered via ASP...
The ASP server looks at the includes first, builds the HTML from all the seperate include files, sends it to your browser peiced togather and the browser then requests the images.
An ASP page (Active Server Page) is very different. Any page that runs ASP must have an extionsion of *.asp rather than *.htm. The include files will also be called *.asp (or *.inc or *.txt). For this tutorial I am going to suggest you use the *.asp extension and not the *.inc or *.txt ones. You will find it a little safer to use the *.asp extension due to the way a server responds to files with *.asp. This boils down to a file called ASP.DLL... suffice to say I wont explain anymore other than that you for simple includes you don't need to know anymore.
By giving the document an ASP extension you change the way a server deals with it. When you request an ASP file the server doesnt send it to you but has a read of it first. It needs to read it first to understand what must be done to , where all the includes can be found and only then put the front end code together before sending it to you.
With our example of SSI's you are telling the server to act like a wharehouse. In essence it reads the code and gets the shopping list together... one of these, two of them and a few of these and then follows instructions to put it together. Only then does it send it to you in the correct order. When you view the source you will not see the includes but the code that it put together like a jigsaw from the invidual includes.
Thus if you give your documents an extension of HTM or HTML the server would not know that it needs to read it first and then act on what it discovers. This doesn't mean that you can't write a normal HTML file and call it ASP. The server will still read it and discover that it has nothing to act on and just serve all the HTML to the browser. This should point out to you that no matter what ever is in your individaul ASP includes your browser still understands HTML and not ASP. ASP is not a language but a way of serving the language. So remember what ever pieces of the jigsaw you use they must end up as valid HTML when they reach the users browser.
Ok I think that is enough for now I will add the next step tomorrow. I will write up the code and show how it can be placed in a structured directory for logical usage and intelligent management of repeatable pieces of your web page. Then finally we will put it all together.
If you have any questions or comments please feel free to add them. It's 4am so go easy on me ;)
I hope that made some sense to someone out there.
Updated edit for Pegs questions... hope they make more sense now.
Intro (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-25590.html) - Pt 2 - Pt3 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-3-the-code-for-our-example-25644.html) - Pt4 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-4-save-the-code-30534.html) - Pt5 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-5-yay-it-is-all-over-30535.html)