21
1 Software Testing and Quality Assurance Lecture 33 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques

1 Software Testing and Quality Assurance Lecture 33 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

1

Software Testing and Quality Assurance

Lecture 33 – SWE 205

Course Objective:Basics of Programming Languages &

Software Construction Techniques

2

Lecture Outline

Script code Submitting the Form data Introduction to Active Server Pages (ASP)

3

Client 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.

4

Client Side Scripting Many scripting languages; for example

VBScript and JavaScript.

5

Client Side Scripting - Example<html>

<head><title> This is Cars web site</title>

</head><script id=“clientEventHandlersJS” language=“javascript”><!- -

function btnhelp_onclick() {//Help the user along.alert (“Please click Submit….”);

}//--><body BGCOLOR=“#66ccff”><!--

<form name=“MainForm” ID =“Form1”><p align=“center”><input id=“btnHelp” type=“button” value=“help”Name=“btnHelp” onClick=“return btnHelp_onClick()”> </P></form></body></html>

6

Submitting 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 <form> tag

To specify the recipient of the incoming form data.

7

Submitting the Form Data - GET Possible receivers include

Mail servers, other HTML files, An Active Server Page (ASP) …… etc.

For example,<form name=“MainForm” ID=“MainForm”Action=http://localhost/Cars/xxxxx.asp method

= “GET”>…..</form>

8

Submitting 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.

9

Submitting 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?txtUserName=Ahmed&txtPassword=mypassword&btnSubmit=Submit

10

Submitting the Form Data - POST The other method of transmitting form

data to the Web Server is To specify method = “POST”

<form name=“MainForm” ID=“MainForm”Action=http://localhost/Cars/xxxxx.asp

method = “POST”>…..</form>

11

Submitting 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.

12

A 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.

13

A classic Active Server Page - Example<%@ language=“VBScript” %><html><head>

<title>The Cars Page</title></head><body>

<h1 align=“center”Here is what you sent me: </h1><P align=“center”<b>User Name: </b><%=Request.QueryString(“txtUserName”) %><b>Password: </b><%=Request.QueryString(“txtPassword”) %></P></body></hmtl>

Begins and ends with standard tags.

To examine the values contained in each HTML widgetsubmitted via method = “GET”

14

A classic Active Server Page - Example<%@ language=“VBScript” %><html><head>

<title>The Cars Page</title></head><body>

<h1 align=“center”Here is what you sent me: </h1><P align=“center”<b>User Name: </b><%=Request.QueryString(“txtUserName”) %><b>Password: </b><%=Request.QueryString(“txtPassword”) %></P></body></hmtl> <%= …%> Insert the following

directly into the HTTP response.

15

A 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.

16

Responding the POST submissions

<body><h1 align=“center”Here is what you sent me: </h1>

<P align=“center”<b>User Name: </b><%=Request.Form(“txtUserName”) %><b>Password: </b><%=Request.Form(“txtPassword”) %></P></body> Note: Request.QueryString() method

is only able extract data submittedvia the GET method.

17

Problems 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.

18

Problems 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.

19

Problems 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).

20

Problems with Classic ASP Classic ASP demands a good deal of

Redundant script code that tends to repeat between projects.

21

Key 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.