Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > All Around Tutorials
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 06-16-2003, 11:30 PM
  #1
entimp
I Quit WoW - Gimme Rep.
 
entimp's Avatar
 
Join Date: May 2002
Location: Liverpool UK (sometimes London)
Posts: 4,897
iTrader: (0)
entimp will become famous soon enough
SSI Server Side Includes Tutorial. Pt 2: The SSI

Intro - Pt 2 - Pt3 - Pt4 - Pt5

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
  • Footer
All 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:
Code:
<!--#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 - Pt 2 - Pt3 - Pt4 - Pt5
__________________

Last edited by Horus_Kol : 08-26-2008 at 05:35 AM. Reason: navigation
entimp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-17-2003, 12:52 AM
  #2
Pegasus
Extremely Flighty Admin
 
Pegasus's Avatar
 
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,465
iTrader: (0)
Pegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to all
This is the part that confused me the first time round, so let's see if I've got it.

A .txt file could be one of my stories. A .inc file could be... maybe a page that contains java script? Like a drop-down menu or something? Or just images or html? Well, images with html, of course. And a .ASP file could be either?

So, to use your grocery shopping analogy, a regular .htm or .html file is like having the clerk put everything in a plastic bag and handing it to me.

An .shtm or .shtml file is like reminding the clerk to put the eggs and cheese in one bag and the bread and cookies in another. That's what I have to save my main file as, isn't it? I'm pointing out that there are "special" things about this information that have to be dealt with.

A .ASP extension is like having the clerk make sure that none of the eggs are damaged by looking inside the carton. Or that none of the cookies are broken by looking through the plastic.

If you use a .txt extension or a .inc extension, the clerk doesn't always "check the eggs", but a .ASP extension forces them to.

Silly question, but why would you need the server to look at the content files? I can see having it look at the first page for complete instructions, but the interior bits? Or is that just so that everything that might be needed for the page - scripts, images and so on - is collected before the page is put on the screen and the viewer doesn't have those annoying blank spaces that sometimes show up on some pages?

Peg
__________________


Decaf is the root of all evil...
HTMLForums Awards 2008
Pegasus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-17-2003, 03:33 AM
  #3
entimp
I Quit WoW - Gimme Rep.
 
entimp's Avatar
 
Join Date: May 2002
Location: Liverpool UK (sometimes London)
Posts: 4,897
iTrader: (0)
entimp will become famous soon enough
Ok I will address theses points in an edit tonight. Off home for now.
__________________
entimp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-17-2003, 06:24 AM
  #4
leoo24
Just 1 of the crowd again
 
leoo24's Avatar
 
Join Date: Dec 2002
Location: under a palm tree watching the waves
Posts: 2,902
iTrader: (0)
leoo24 is on a distinguished road
Great tutorial there entimp, but maybe it's a little advanced for some people, I think most people will dealing with static html pages (or .inc pages) and wouldn't need to deal with asp at this point, maybe it's making it a little harder, dunno just thought i'd say
Are you going to show people how to implement an SSI within some code?

Peg, you are correct , this is the basic/more common application of SSI, you can if you want include a CGI program's results, change the date of a file/echo the date of a file, set variables etc...

/edit
sorry entimp it didn't click this was part 2, i should have commented in the other thread, oops

Last edited by leoo24 : 06-17-2003 at 12:28 PM.
leoo24 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-17-2003, 06:14 PM
  #5
Pegasus
Extremely Flighty Admin
 
Pegasus's Avatar
 
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,465
iTrader: (0)
Pegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to all
You mean I do understand this? Wow!

Oh, I know there's lots of things that can be put on the .ASP pages. I just wasn't sure why I'd be using them. Now that I think about it, though, if I got into the habit of using .asp as an extension, then I wouldn't forget to use it if I ever got advanced enough to really need it. It's like getting into the habit of using the 8.3 extension rule for PCs.

Peg
__________________


Decaf is the root of all evil...
HTMLForums Awards 2008
Pegasus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-21-2004, 05:13 PM
  #6
sh00ter555
Champion (Level 13)
 
sh00ter555's Avatar
 
Join Date: Nov 2003
Posts: 240
iTrader: (0)
sh00ter555 is on a distinguished road
entimp

Hi entimp,
Your tutorial is excellent.
I know its been a long time now that you have written this tutorial, but i am a little behind. I was serching htmlforums for information and found your tutorial. I just finished reading all of your parts 1-5. I think though where i got confused was on this part here.(pt.2). I know you explained why to use .asp but i am am not very advanced and dont know exactly what you mean. I guess what im trying to say is that is it still possible to make a table using .html? Also, i dont think my free server host provider provides the .asp file extensions. Do you know a free host that does? I currently use www.freewebs.com
Also, i have a few other questions but im ganna post them in the relative section of your 5 parts.

PS: do you have aim or something? So i can get a hold of you immediatly if i have a questions?
__________________
Visit my work site that i made:
Valentino's Take n' Bake Pizza
or visit my fun site that i made when i was bored:
MyFlashAnimations
sh00ter555 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-24-2004, 12:46 AM
  #7
entimp
I Quit WoW - Gimme Rep.
 
entimp's Avatar
 
Join Date: May 2002
Location: Liverpool UK (sometimes London)
Posts: 4,897
iTrader: (0)
entimp will become famous soon enough
ASP pages are built with normal HTML and ASP server end stuff. That doesn't mean an ASP page has to have any ASP in it, it can be built with just HTML if you wish. Just design the pages as you would normally... tables as well.

I am trying to think of a good example to get the idea across.

Think of includes as peices of a jigsaw puzzle, just that each peice can be used more than once. You can break your HTML code up and save them as individual files and have them called up as includes and placed into your puzzle in the way you see fit.

Imporatant: Files have to have a server side extension like ASP, PHP, SHTML or they wont work.

These files are all built with normal HTML, well in this example at any rate.

Any other questions then fire away.
__________________
entimp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-06-2004, 09:23 AM
  #8
Aboveaverage
Lord (Level 16)
 
Aboveaverage's Avatar
 
Join Date: Oct 2003
Location: At the computer, just like you.
Posts: 553
iTrader: (0)
Aboveaverage is on a distinguished road
Entimp, several questions.

1) I read at htmlgoodies that

<%@ LANGUAGE="VBSCRIPT" %>

must be the first line of an asp file. On my test at my webhost, I tried adding that and it ended up showing on the page. What happened...

2) I tried a test at my webhost, an intro.asp file that includes table.asp.
After uploading, the intro.asp page was viewable in my browser, but the table.asp file didn't get included. The intro.asp file was a basic web page, with head, body, all in html. I just cut out a table from the layout to make the table.asp include.

3) I am mostly interested in using ASP for SSI. The intro.asp page has in its header a line for the stylesheet, but when I viewed the intro.asp page in my browser, apparently the stylesheet wasn't accessed? No styles showed.

4) Does this mean my webhost doesn't allow ASP, but I could view the intro.asp page... or what did I do wrong?
__________________
"Many of life's circumstances are created by three basic choices: the disciplines you choose to keep, the people you choose to be with; and, the laws you choose to obey. -- Charles Millhuff"


Last edited by Aboveaverage : 05-27-2004 at 01:17 PM.
Aboveaverage is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-20-2004, 11:25 AM
  #9
avaloncm
Swordman (Level 9)
 
avaloncm's Avatar
 
Join Date: May 2004
Posts: 84
iTrader: (0)
avaloncm is on a distinguished road
JSP

Entimp,
I am totally new to this, just reading your tutorials over and over again. Can I use .jsp extension instead of .asp. Does the same apply that this will work with only html in the file?
avaloncm is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-14-2005, 10:10 PM
  #10
entimp
I Quit WoW - Gimme Rep.
 
entimp's Avatar
 
Join Date: May 2002
Location: Liverpool UK (sometimes London)
Posts: 4,897
iTrader: (0)
entimp will become famous soon enough
Sorry... missed all these... just going over them for future readers as well.

Quote:
Originally posted by Aboveaverage
Entimp, several questions.

1) I read at htmlgoodies that

<%@ LANGUAGE="VBSCRIPT" %>

must be the first line of an asp file. On my test at my webhost, I tried adding that and it ended up showing on the page. What happened...

2) I tried a test at my webhost, an intro.asp file that includes table.asp.
After uploading, the intro.asp page was viewable in my browser, but the table.asp file didn't get included. The intro.asp file was a basic web page, with head, body, all in html. I just cut out a table from the layout to make the table.asp include.

3) I am mostly interested in using ASP for SSI. The intro.asp page has in its header a line for the stylesheet, but when I viewed the intro.asp page in my browser, apparently the stylesheet wasn't accessed? No styles showed.

4) Does this mean my webhost doesn't allow ASP, but I could view the intro.asp page... or what did I do wrong?
1: No you do not need to include the declaration: <%@ LANGUAGE="VBSCRIPT" %>

That tells the server/browser what language the code is written in. We haven't done any scripting.

If you use some VB then you will.

2: would have to see your code. If you still want to show it.

3: Is the root to the CSS correctly sourced? Try writing in the full web address of it.

4: I dont know... you will have to contact your host and see if they offer asp, will usually be extra though.
__________________
entimp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-14-2005, 10:12 PM
  #11
entimp
I Quit WoW - Gimme Rep.
 
entimp's Avatar
 
Join Date: May 2002
Location: Liverpool UK (sometimes London)
Posts: 4,897
iTrader: (0)
entimp will become famous soon enough
Re: JSP

Quote:
Originally posted by avaloncm
Entimp,
I am totally new to this, just reading your tutorials over and over again. Can I use .jsp extension instead of .asp. Does the same apply that this will work with only html in the file?
Not sure what JSP is?

Sounds like java script. If it is, I doubt it.

You need a server side based tool like PHP, ASP.NET or ASP.
__________________
entimp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-14-2005, 10:44 PM
  #12
Pegasus
Extremely Flighty Admin
 
Pegasus's Avatar
 
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,465
iTrader: (0)
Pegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to all
.jsp? Isn't that the extension for JScript, the Windows-only variation on Javascript?

Peg
__________________


Decaf is the root of all evil...
HTMLForums Awards 2008
Pegasus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-20-2005, 12:48 AM
  #13
Erikina
Catapulted
 
Erikina's Avatar
 
Join Date: May 2004
Location: threadid=49138
Posts: 1,131
iTrader: (0)
Erikina is on a distinguished road
Quote:
Originally posted by Pegasus
.jsp? Isn't that the extension for JScript, the Windows-only variation on Javascript?

Peg
Nah, JSP is JavaServer Pages it's like Java the programming langauge (not javascript). Since it's quite a powerful language, you could do it - but I'd guess the syntax would be different.
Erikina is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 03-20-2005, 12:51 AM
  #14
Pegasus
Extremely Flighty Admin
 
Pegasus's Avatar
 
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,465
iTrader: (0)
Pegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to all
That makes sense. I know there's a difference between Java and Javascript, but don't ask me to tell you. *g* I'm still working on separating Javascript and HTML.

Peg
__________________


Decaf is the root of all evil...
HTMLForums Awards 2008
Pegasus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 09:13 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.