Title: Software Testing and Quality Assurance
1Software Testing and Quality Assurance
- Lecture 33
- SWE 205
- Course Objective
- Basics of Programming Languages Software
Construction Techniques
2Lecture Outline
- Script code
- Submitting the Form data
- Introduction to Active Server Pages (ASP)
3Client Side Scripting
- Any given .html file may contain blocks script
code - Processed by the requesting browsers.
- Reasons client side scripting is used
- To validate user input before posting back to the
web server. - To interact with Document Object Model (DOM) of
the target browser.
4Client Side Scripting
- Many scripting languages for example
- VBScript and JavaScript.
5Client Side Scripting - Example
- lthtmlgt
- ltheadgt
- lttitlegt This is Cars web sitelt/titlegt
- lt/headgt
- ltscript idclientEventHandlersJS
languagejavascriptgt - lt!- -
- function btnhelp_onclick()
- //Help the user along.
- alert (Please click Submit.)
-
- //--gt
- ltbody BGCOLOR66ccffgt
- lt!--
- ltform nameMainForm ID Form1gt
- ltp aligncentergtltinput idbtnHelp
typebutton valuehelp - NamebtnHelp onClickreturn btnHelp_onClick()gt
lt/Pgt - lt/formgt
- lt/bodygt
- lt/htmlgt
6Submitting the Form Data
- Once you have a simple HTML page
- Need to examine how to transmit the form data
back to the Web Server for processing. - While building an HTML form,
- We typically supply an action attribute on the
opening ltformgt tag
To specify the recipient of the incoming form
data.
7Submitting the Form Data - GET
- Possible receivers include
- Mail servers, other HTML files,
- An Active Server Page (ASP) etc.
- For example,
- ltform nameMainForm IDMainForm
- Actionhttp//localhost/Cars/xxxxx.asp method
GETgt - ..
- lt/formgt
8Submitting the Form Data - GET
- When the submit button for current form is
clicked, - the form data should be sent to the xxxx.asp file
located within the Cars virtual directory.
9Submitting the Form Data - GET
- GET as a mode of transimission
- The form data is appended to the query string as
a set of name/value pairs - For example,
- http//localhost/Cars/xxxxx.asp?txtUserNameAhmed
txtPasswordmypasswordbtnSubmitSubmit
10Submitting the Form Data - POST
- The other method of transmitting form data to the
Web Server is - To specify method POST
- ltform nameMainForm IDMainForm
- Actionhttp//localhost/Cars/xxxxx.asp method
POSTgt - ..
- lt/formgt
11Submitting the Form Data - POST
- The data is not appended to the query string
- But instead is written to a separate line within
the HTTP header. - The data is directly visible to the outside word
and - A wee bit more secure.
12A classic Active Server Page
- Goal of ASP is to
- Dynamically build HTML on the fly using
server-side script logic and - A small set of classic COM objects and related
COM libraries. - For example,
- A server side VBScript (or JavaScript) block that
reads a table from a data source - Using classic ADO and returns
- The rows as a generic HTML Table.
13A classic Active Server Page - Example
- lt_at_ languageVBScript gt
- lthtmlgt
- ltheadgt
- lttitlegtThe Cars Pagelt/titlegt
- lt/headgt
- ltbodygt
- lth1 aligncenterHere is what you sent me
lt/h1gt - ltP aligncenterltbgtUser Name lt/bgt
- ltRequest.QueryString(txtUserName) gt
- ltbgtPassword lt/bgt
- ltRequest.QueryString(txtPassword) gt
- lt/Pgt
- lt/bodygt
- lt/hmtlgt
Begins and ends with standard tags.
To examine the values contained in each HTML
widget submitted via method GET
14A classic Active Server Page - Example
- lt_at_ languageVBScript gt
- lthtmlgt
- ltheadgt
- lttitlegtThe Cars Pagelt/titlegt
- lt/headgt
- ltbodygt
- lth1 aligncenterHere is what you sent me
lt/h1gt - ltP aligncenterltbgtUser Name lt/bgt
- ltRequest.QueryString(txtUserName) gt
- ltbgtPassword lt/bgt
- ltRequest.QueryString(txtPassword) gt
- lt/Pgt
- lt/bodygt
- lt/hmtlgt
lt gt ? Insert the following directly into the
HTTP response.
15A classic Active Server Page - Example
- Load the default.html page and submit the data.
- Once script is processed on the web server, a
dynamic HTML page is displayed.
16Responding the POST submissions
- ltbodygt
- lth1 aligncenterHere is what you sent me
lt/h1gt - ltP aligncenterltbgtUser Name lt/bgt
- ltRequest.Form(txtUserName) gt
- ltbgtPassword lt/bgt
- ltRequest.Form(txtPassword) gt
- lt/Pgt
- lt/bodygt
Note Request.QueryString() method is only able
extract data submitted via the GET method.
17Problems with Classic ASP
- Perhaps, the biggest downfall of classic ASP is
the same point that makes it a powerful platform.
- Server side scripting language.
- Scripting languages are interpreted
- Thus, not robust as OO programming techniques.
18Problems with Classic ASP
- For example, under classic ASP
- There were not concept of classical inheritance
or classical polymorphism. - It does not generate very modularized code.
19Problems with Classic ASP
- ASP is a blind of HTML and script in a single
page - Most ASP web applications are a confused mix of
two very different programming techniques. - A web framework would allow the presentation
logic (i.e. HTML tags) to - Exist independently from the business logic (i.e.
functional code).
20Problems with Classic ASP
- Classic ASP demands a good deal of
- Redundant script code that tends to repeat
between projects.
21Key Points
- HTML files usually contain blocks of script code.
- GET and POST methods to transmit the data
back to the web servers for processing. - ASP aim to dynamically build HTML using script
logic and small set of COM objects.