Serverside JavaScript ASP - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Serverside JavaScript ASP

Description:

An ASP page is an HTML page interspersed with server-side code. ... VBScript. JavaScript. ActiveX Scripting. Engines. ASP File. HTTP Request. HTTP Response ... – PowerPoint PPT presentation

Number of Views:72
Avg rating:3.0/5.0
Slides: 11
Provided by: cms98
Category:

less

Transcript and Presenter's Notes

Title: Serverside JavaScript ASP


1
Session 4
  • Server-side JavaScript ASP
  • and SQL

2
What is ASP?
  • An ASP page is an HTML page interspersed with
    server-side code.
  • The .ASP extension instead of .HTM denotes
    server-side code to the hosting Web server.
  • You can use any text editor to create or change
    an ASP file

Sets the default for the page
lt_at_LANGUAGE "JavaScript"gt lt var varSurname
Request.form("surname") gt lthtmlgt ltbodygt lt sql
"Select from tblStock" gt THIS IS
HTML Surname ltvarSurnamegt
Gets data from form on previous page
The ASP is between lt and gt
Outputs the variables content
3
Browsers
  • Display data primarily in HTML format.
  • Accept user input from HTML form elements
  • ASP pages are a mixture of hard-coded HTML (menu
    bars, other static page content) and dynamically
    generated HTML.
  • ASP (operating at the server-side) must therefore
    send the data from the server to the client in
    HTML format. All the calculations for doing this
    are performed at the server side, using the
    server's processor.

4
Client
HTTP Request
Web Server
HTTP Response
Components
ActiveX Data Objects (ADO)
VBScript
IIS
JavaScript
ActiveX Scripting Engines
Database
ASP File
5
Stages for ASP
  • Client requests ASP page from server
  • HTML and script code are separated.
  • Script code is parsed, syntax checked and
    compiled by Web server by appropriate scripting
    engine
  • Code is executed by the appropriate scripting
    engine
  • Script output and static HTML code are merged
  • Final HTML is sent back to the user

6
Anatomy of an .asp Page
lthtmlgt ltheadgt lt/headgt ltbodygt lt/bodygt lt/htmlgt
Note the code appears where the data will be
output on screen.
7
Open Database Connectivity (ODBC)
These databases know how to interact with ODBC
  • ODBC is an intermediary technology that allows
    databases made by different manufacturers to
    communicate with different interfaces e.g. ASP
    pages.
  • The web server has ODBC drivers installed upon it
    which interpret the dialogue into a common
    language that each database understands.

Adapted from Resselman, 2000
8
Returning Records from a DB Using ASP
  • Open a connection to the database, using the
    connection object.
  • Create a query string variable containing the SQL
    for the query.
  • Create a recordset object, then run the query on
    it.
  • Loop through the records and format and display
    each as HTML.

9
lt_at_ LANGUAGE"JAVASCRIPT" gt lt myconn
CreateObject("ADODB.Connection") rs
CreateObject("ADODB.Recordset") myDB
"DriverMicrosoft Access Driver
(.mdb)DBQe\\webareas\\sr65\\sdg.mdb"
10
sql "Select from tblStock order by
Stock_id" rsmyconn.Execute(sql) while (!
rs.eof) gt Item ltrs("Description")gtltbr
/gt lt rs.MoveNext() rs.Close() gt
Write a Comment
User Comments (0)
About PowerShow.com