Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing...

13
CT1501 DEVELOPMENT OF INTERNET APPLICATION Creating Web Pages with ASP Prepared By: Huda Alsuwailem Reviewed by: Rehab Alfallaj www.faculty.ksu.edu.sa/rehab-alfallaj [email protected]

Transcript of Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing...

Page 1: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

CT1501 DEVELOPMENT OF INTERNET

APPLICATION

Creating Web Pages with ASP

Prepared By: Huda Alsuwailem

Reviewed by: Rehab Alfallaj

www.faculty.ksu.edu.sa/rehab-alfallaj [email protected]

Page 2: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

ASP

ASP is a shortcut of Active Server Pages

it was the first Server Side Script engine for

developing Dynamically generated web pages.

We need to install Internet Information Server

OR Personal Web Server (Why?)

Start > Control Panel > Programs > Programs

and Features > Turn Windows Features on or off

> check IIS

Now your PC will act as a real server working on

Web :)

Page 3: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

IIS OR PWS ?

برنامج خادم الويب نظام التشغيل

Win NT Server IIS

Win 2000 workstation/Server IIS

Win XP IIS

Win 9X (98/95) PWS

Page 4: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

ASP SYNTAX

any ASP server script must be surrounded by the

symbols <% … %>

Example:

<!DOCTYPE html>

<html>

<body>

<%

response.write("My first ASP script!")

%>

</body>

</html>

Page 5: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal
Page 6: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

ASP OBJECTS

1. Response:

The ASP Response object is used to send output to the user from the server

Properties:

response.Buffer[=Flag ]

Methods:

Redirect Redirects the user to a different URL

Write Writes a specified string to the output

Clear Clears any buffered HTML output

End Stops processing a script, and returns the current result

Flush Sends buffered HTML output immediately

Page 7: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

RESPONSE

Example1 :

<%

Response.Redirect "http://www.w3schools.com"

%>

Page 8: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

RESPONSE

Example 2 :

<%

Response.Write "Hello World"

%>

Example 3:

<%

name="John"

Response.Write(name)

%>

Page 9: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

REQUEST

2. Request.

The Request object is used to get information from a

visitor.

Methods:

BinaryRead Retrieves the data sent to the server from

the client as part of a post request and stores it in a

safe array

Collections:

Form Contains all the form (input) values from a form

that uses the post method (POST Method)

QueryString Contains all the variable values in a

HTTP query string (GET Method)

ServerVariables Contains all the server variable values

Page 10: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

REQUEST

Example 1:

<HTML>

<BODY>

<CENTER>

<B> قائمة بجميع متغيرات الخادم هذه <BR>

<%

For Each Var in Request.ServerVariables

Response.Write(Var & "<BR>")

Next

%>

</B>

</CENTER>

</BODY>

</HTML>

Page 11: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

REQUEST

Example 2:

<%

Dim ServerVal

ServerVal=Request.ServerVariables("SERVER_

NAME")

Response.Write(" <CENTER>SERVER_NAME =

" & ServerVal & "</CENTER>")

%>

Page 12: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

ASP OBJECTS

3. Session :

A Session object stores information about, or change

settings for a user session.

4. Application:

The Application object is used to store and access

variables from any page

5. Server:

The Server object is used to access properties and

methods on the server.

6. Error:

The ASPError object displays information about

errors in scripts.

Page 13: Creating Web Pages with ASPfac.ksu.edu.sa/sites/default/files/lecture4_0.pdf · developing Dynamically generated web pages. We need to install Internet Information Server OR Personal

REFERENCES:

http://lessons.roro44.com/lessons-42-927-0.html

http://lessons.roro44.com/lessons-42-928-0.html

http://en.wikipedia.org/wiki/Active_Server_Pages

#The_Request_object

http://www.w3schools.com/asp/default.asp