Title: Week 7: Introduction to serverside scripting
1Week 7 Introduction to server-side scripting
- How a server side page works?
- - Basically, A Web requires two components a
Web server and a client - - The client is usually a browser (I.E/Netscape
etc) - - Both the server the client can communicate
each other. - - Must use a defined protocol to communicate
- - The most common protocols are HTTP FTP and
also carried over an underlying network protocol
called TCP/IP - - The client sends an initialization (is a
defined series of bytes) to start a session, when
the server receives the initialization request,
it acknowledges the transmission by returning
another series of bytes to the client. - - The conversation between client server
continues in this back-and forth manner.
2Week 7 Introduction to server-side scripting
- - You can imagine the conversation being
conducted as follows - Client Hello?
- Server Hello. I speak English.
- Client I speak English too.
- Server What do you want?
- Client I want the file /mySite/myFiles/file1.htm
- Server Heres some information about that file
- Client Thanks, please send the data
- Server Starting data transmission
- Client I got packet 1. Send packet 2.
- Server Sending packet 2.
- ----------
- Server All packets sent.
- Client All packets received in good condition.
Goodbye! - Server Goodbye!.
3Week 7 Introduction to server-side scripting
- 1 What is ASP
- - Stands for Active Server Pages
- - An ASP is a Web page that is processed by a
web server - - ASP is a Microsoft technology
- - ASP is a program that runs inside a web
server (IIS/PWS) - - IIS is Internet Information Services comes as
a free component with windows 2000 windows NT
4.0 option pack - - PWS is Personal Web Page, a smaller scale
version but fully function like IIS - - ChileASP/InstantASP is a technology that runs
ASP without Windows OS - - An ASP file can contain text, HTML, XML and
scripts. The file extension- .asp - - Scripts in an ASP file are executed on the
server.
4Week 7 Introduction to server-side scripting
- 2. Working with IIS/PWS and ASP
- - You can choose either IIS/PWS as a web server
to run your ASP file - - If you choose IIS, you must have access to a
Windows NT 4.0 server with IIS 4.0 or Windows
2000 Server with IIS 5.0. - - Or you can install PWS on your local hard
disk and enables you to work as same as ISS. - - PWS/IIS designate a master directory on the
hard drive that contains all date and script file
for use by Internet Server. - - The default master directory is \InetPub
- - You can place your ASP file under
subdirectory \wwwroot (Example
C\InetPub\wwwroot\MyFirstAsp.asp) - - IIS/PWS have built-in intelligence that knows
to route a request for a Web page using HTTP to
this directory.
5Week 7 Introduction to server-side scripting
- JavaScripts (Jscript) vs. VBScript
- - By default, ASP using VBScript because ASP is
Microsoft technology - - But we can choose other languages like
JavaScript or JScript by specifying the language
like lt _at_Language JavaScript gt - - JavaScript is Netscapes cross platform which
is used originally as a scripting language for
Netscape browser. - - Basically, Jscript is the same thing but
often used by Microsoft. - - Most of the resources about ASP use the
VBScript scripting language and JavaScript most
popular on the client side scripting language.
6Week 7 Introduction to server-side scripting
- -
- We use JavaScript on the ASP for a number of
reasons - o JavaScript is an open protocol. VBScript
is not - o JavaScript is case-sensitive, where
VBScript is not. - o JavaScript is larger and more complex
language than VBScript. - o JavaScript is more aware of HTML than
VBScript and has numerous - formatting and parsing methods for
creating and analyzing HTML tags. - o JavaScript is, in some ways, more
powerful than VBScript. VBScript - version 5 has almost closed the gap.
-
7Week 7 Introduction to server-side scripting
- Basic ASP scripting style
- -Server side scripting is a script that is
executed by the web server, then the results of
which are passed on to the calling client. - -It begins with lt _at_LANGUAGE JAVASCRIPT gt
(this is for JavaScript) - -So, we must put tag lt . gt and start
writing code in between the tags. - - Example 1.5_my_first.asp
8Week 7 Introduction to server-side scripting
- lt_at_LANGUAGE"JAVASCRIPT"gt
- lthtmlgt
- ltheadgt
- lttitlegtMy First ASPlt/titlegt
- lt/headgt
- ltbodygt
- lt
- Response.Write("This is my first ASP")
- gt
- lt/bodygt
- lt/htmlgt
9Week 7 Introduction to server-side scripting
- - Style of writing scripts
- 1. Writing Inline Script
- -Means that the server-side scripting engine in
the order that it appears in the ASP page
executes the script. - -You can indicate inline server-side script in
your page by placing the programming statements
between the following tags lt gt. - Example 1.5_inline.asp
10Week 7 Introduction to server-side scripting
- lt_at_LANGUAGE"JAVASCRIPT"gt
- lthtmlgt
- ltheadgt
- lttitlegtMy First ASPlt/titlegt
- lt/headgt
- ltbodygt
- lt
- var now new Date()
- Response.Write("This is my first ASPltbrgt")
- Response.Write(now)
- gt
- lt/bodygt
- lt/htmlgt
11Week 7 Introduction to server-side scripting
-
- 2. Interspersing Inline Script
- -You can intersperse inline script within an ASP.
- -The script is executed in the order in which it
is encountered - -Example 1.5_intersperse.asp
12Week 7 Introduction to server-side scripting
- lt_at_LANGUAGE"JAVASCRIPT"gt
- lthtmlgt
- ltheadgtlttitlegtMy First ASPlt/titlegtlt/headgt
- ltbodygt
- lt
- var now new Date()
- Response.Write("ltBgt" "This is my second
ASP" "lt/Bgt" "ltbrgt") - Response.Write(now.toString() "ltBRgt")
- gt
- lt
- now.setDate(now.getDate()-1)
- Response.Write("This was my first
ASPltbrgt") - Response.Write(now.toString())
- gt lt/bodygt lt/htmlgt