Making communications land - Are they received and understood as intended? we...
Server side scripting
1.
2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of
mentoring program. This is not official document of baabtra – Mentoring
Partner
baabtra – Mentoring Partner is the mentoring division of baabte System Technologies Pvt. Ltd
4. Static Web Pages
1. Client requests page
Internet
2. Web server sends the HTML file to the client
Client Machine
Web Server
With Web Browser
• A simple website is made up of one or more static HTML files. This means the page content does not change.
• The only way to update a page is for the author to edit the file.
• This is fine for small websites or those that require little updating.
• Static pages will not work for websites that need to deliver lots of custom and up-to-date content. Examples of these sites are:
•Shopping / auctions
•Discussion forums
•Search engines
•Online banking
•Blogs
•Web-based email
• These types of websites rely on dynamic content so cannot be served by static pages. They need to be able to display content taken
from a database or other source.
• This is where server-side scripting is needed.
5. Dynamic Web Pages
The Google homepage could be
considered static because it has a
Static
fixed layout and content. It does not
change.
A search results page however is
dynamic. This means its content can
be changed.
The only practical way to create this page
is by using a script, otherwise Google
would have to create a static results
page in advance for every single
possible search.
Dynamic
The user never sees the work a script
does, only the end result it send back
to their web browser.
6. Scripting Languages
A script creates what appears to be a static web page using content generated
or read from a data source.
There are many scripting languages, made by different companies and
organisations.
The current most popular are ASP, PHP and Ruby on Rails.
All are very powerful and work in slightly different ways.
It does not matter what scripting language a website uses because there are
no compatibility issues with clients’ web browsers.
The client only ever sees the final HTML generated by the script and not the
script itself.
Scripts often finish running in several milliseconds. Most web servers can run
many scripts simultaneously with a minimal performance hit.
7. Scripting Languages
You can sometimes tell which scripting language a website is using by looking
at the address bar.
Text after a question mark in an address is parameters and variables sent to
the script.
Some website developers choose to design their sites in a way that hides
evidence of server-side scripting. They do this by telling the web server to
use the scripts while hiding or changing the text in the address bar. This is
usually just to tidy the appearance or shorten the length of the address
bar, making it easier to read or copy.
8. How Scripting Languages Work
Server runs script
Client requests page [ ASP / PHP / Ruby ]
Script
Internet
Script builds
Completed HTML sent to client HTML code
Web Server HTML ready to send
HTML Code
Client Machine
With Web Browser
• The script, written by the website developer, generates the HTML code of the page requested.
• The HTML is not actually a file. The code is actually held in the server’s memory until it is sent
directly to the client.
• A script may run other scripts, depending on its function. It will however still only give one end
result.
• A website does not have to be completely made up of either scripts or HTML files. It can use a
combination of the two.
9. Databases
One of the most useful features of nearly all of the scripting languages is their ability
to enter and retrieve information from a database.
Like scripting languages, there are many free and commercial database applications
available.
Some are designed to be used by small websites (such as MySQL) whereas others (eg.
Oracle) are very powerful, have dedicated servers and are used by large companies
and organisations.
Scripts interact with databases using Structured Query Language (SQL). This is a very
simple text language that allows nearly any script to communicate with nearly any
database, practically eliminating any compatibility issues.
This also allows a website developer to change/upgrade the database application their
website uses with minimal changes to their code.
A website script can change the data in a database as well as retrieving it.
10. Scripts & Databases
1. Server receives request
for web page
2. Server begins to run script
1. Client requests page
3. Script requests data from
Internet the database using SQL
4. Script processes the
6. Completed HTML sent to client returned data and
formats it as needed
5. Script builds the HTML [ Oracle /
Web Server code to create the MySQL /
requested page PostgreSQL ]
Client Machine Database
With Web Browser 6. Completed HTML page
sent back to the client’s
web browser
[ ASP / PHP / Ruby ] Script
• Again, the script on the server is generating all of the HTML code, but this time it is getting some
content of the page from a database. As far as the web browser (and the user) is concerned, all
they see is the end result, a completed web page.
• The script requests the raw data it needs from the database using Structured Query Language
(SQL). The database immediately returns the data requested by the script.
• Now that the script has the data it needs, it can build the HTML code to send back to the client.