ASP (Active Server Page) : Morteza Sargolzaie Javan IT Scientific Society
ASP (Active Server Page) : Morteza Sargolzaie Javan IT Scientific Society
2 5
Client requests page Browser processes
page
2 6
Client requests page Browser processes
page
Client
IT Scientific Society - December 2006 8
Many Technology Choices
Client-Side Technologies:
Scripting languages: JavaScript, VBScript
Java applets
XML
Server-Side Alternatives:
CGI
Active Server Pages (ASP)
PHP
Java Server Pages (JSP)
ColdFusion
Author writes 4 Web server asks script engines to process scripts & generate HTML
page code
5 HTML stream passed back to server
6
Browser processes
2 client side scripts
Client requests page 7
Browser processes
HTML & displays
page
Client
IT Scientific Society - December 2006 11
ASP – Middleware for Windows platform
ASP stands for Active Server Pages
Server locates
Client requests Client
the ASP file on
the hard drive ASP File
and parses it,
removing all
ASP script and
replacing it with
HTML text Server returns HTML
text to client
<HTML>
<HEAD> <TITLE>Hello World</TITLE>
Result on </HEAD><BODY>
Client Hello, ASP World!
</BODY></HTML>
http://localhost/page.asp
http://127.0.0.1/page.asp
http://[Computer-name]/page.asp
server variables
Example <% Request.QueryString
(“fname”) %>
JavaScript
<%@ language="javascript" %>
<html>
<body>
<% Response.Write("Hello World!") %>
</body>
</html>
<%
dim name
name=“Javan"
response.write("My name is: " & name)
%>
</body>
</html>
<%
Dim famname(6),i
famname(1) = "Jan Egil"
famname(2) = "Tove"
famname(3) = "Hege"
famname(4) = "Stale"
famname(5) = "Kai Jim"
famname(6) = "Borge"
For i = 1 to 6
response.write(famname(i) & "<br />")
Next
%>
</body>
</html>
IT Scientific Society - December 2006 42
Loops
<html>
<body>
<%
dim i
for i=1 to 6
response.write("<h" & i & "> Header " & i & "</h" & i & ">")
next
%>
</body>
</html>
If h<12 then
response.write("Good Morning!")
else
response.write("Good day!")
end if
%>
</body>
</html>
Response.Write("<p>“ + d + “</p>”)
if (h<12)
{
Response.Write("Good Morning!")
}
else
{
Response.Write("Good day!")
}
%>
</body>
</html>
if numvisits="" then
response.cookies("NumVisits")=1
response.write("Welcome! This is the first time you are visiting this Web page.")
else
response.cookies("NumVisits")=numvisits+1
response.write("You have visited this Web page " & numvisits)
if numvisits=1 then
response.write " time before!"
else
response.write " times before!"
end if
end if
%>
</body>
</html>