SlideShare a Scribd company logo
1 of 26
Introduction to ASPIntroduction to ASP
(Day 1)(Day 1)
JoniJoni
ATL - Bina NusantaraATL - Bina Nusantara
Agenda
• ASP
• Basic Control Flow
– If Then Else
– Select Case
– For Loop
– Do While Loop
• Form Processing
• Server Side Includes
ASP
• Active Server Page
• The default scripting language is
VBScript, but you can use JScript also.
• File extension: .asp
ASP
• Syntax:
– to execute some code <% code %>
– to print a value <%= variable/expression
%>
• Variable
• if then else, for, while
• function / procedure
Variable
<%
option explicit
%>
<html>
<head><title>hello</title></head>
<body>
<%
dim name
name = "Peter"
dim n
n = 18
%>
<p>Hello <%= name %>!<br>
Your age is <%= n %>
</p>
</body>
</html>
‘option explicit’
enforces variable
declaration.
‘option explicit’
enforces variable
declaration.
By default, you don’t need to
declare variables. But for easier
debugging, declare every
variables. Variables can be string,
integer and some other type.
By default, you don’t need to
declare variables. But for easier
debugging, declare every
variables. Variables can be string,
integer and some other type.
ASP using JScript
<%@ Language=Jscript %>
<html>
<head><title>hello</title></head>
<body>
<%
var name = "Peter";
var n = 18;
%>
<p>Hello <%= name %>!<br>
Your age is <%= n %>
</p>
</body>
</html>
ASP-Generated HTML
<html>
<head><title>hello</title></head>
<body>
<p>Hello Peter!<br>
Your age is 18
</p>
</body>
</html>
This is what the browser receives.
The browser doesn’t care
whether this page is generated by
ASP or not. And, it cannot see the
ASP source code.
This is what the browser receives.
The browser doesn’t care
whether this page is generated by
ASP or not. And, it cannot see the
ASP source code.
If Then Else
<% if strName = “Peter” then %>
How are you Peter!
<% else if strName = “Mary” then %>
Dear Mary!
<% else %>
How do you do! <%= strName %>
<% end if %>
Select Case
<%
select case strName
case “Peter”
Response.Write(“…”)
case “Mary”
Response.Write(“…”)
case else
Response.Write(“…”)
end select
%>
For Loop
<table border=“1”>
<% for i = 1 to 7 %>
<tr>
<td><%=i%></td>
<td><font size=“<%=i%>”>hello</font>
</td>
</tr>
<% next %>
</table>
Do While Loop
<%
dim sum, I
i = 1
sum = 0
do while i < 8
sum = sum + I
i = i + 1
if sum > 10 then exit do
loop
%>
Exit the do loop
immediately
Exit the do loop
immediately
Array
<%
dim i
dim A()
redim A(9)
for i = 0 to 9
A(i) = i*i
next
redim preserve A(20)
redim A(15)
dim B(10,10)
%>
Array in VBScript is zero-based,
i.e. it starts at 0.
Dim A(n) wil give an array of size
n+1.
Array in VBScript is zero-based,
i.e. it starts at 0.
Dim A(n) wil give an array of size
n+1.
Resize an array (and
preserve the data)
Resize an array (and
preserve the data)
2D array2D array
Form Processing
• Use tag <form> … </form>
• FORM allows the user to submit data to web
server for processing
• A FORM contains one or more input fields
• After filling the FORM, the user can submit
the data usually by pressing a submit button
Form Sample
<body>
<p>Please fill in the form:</p>
<form action=“process.asp”>
<!-- items goes here -->
<input type=“submit”
name=“btnSubmit”>
</form>
</body>
URL of an ASP
page to process
the submitted
data
URL of an ASP
page to process
the submitted
data
Form Components
• <input type=“text”>
• <input type=“password”>
• <input type=“hidden”>
• <input type=“radio”>
• <input type=“checkbox”>
• <input type=“submit”>
• <select>
<option>…</option>
</select>
• <textarea> … </textarea>
Post Method
<body>
<p>Please fill in the form:</p>
<form action=“process.asp” method=“post”>
<!-- items goes here -->
<input type=“submit” name=“btnSubmit”>
</form>
</body>
The default method of form is “get”.
The data in the form are encoded and
transmitted in the body of the HTTP
request. They are invisible to the user.
The default method of form is “get”.
The data in the form are encoded and
transmitted in the body of the HTTP
request. They are invisible to the user.
If we use method “GET”, the form data are attached to
the URL submitted to the server. e.g.
http://www.test.com/process.asp?name=tom&id=123
If we use method “GET”, the form data are attached to
the URL submitted to the server. e.g.
http://www.test.com/process.asp?name=tom&id=123
GET vs. POST
• Encoded form data are attached to the end
of the URL in GET method
– visible to the end user
– can be saved as bookmark
– we can use such URL to store pre-filled request
• Encoded form data are attached as the
request body in POST method
– necessary for large amount of form data, e.g.
file upload
Server Side Includes
• <!--#Include file=“header.asp”-->
• <!--#Include virtual=“header.asp”-->
Built-in ASP Objects (1/2)
• Application
– Share information among all users of an
application
• Request
– Get information passed in HTTP request, e.g.
user input in FORM and file upload
• Response
– Send information to browser, set cookies, and
redirect to another URL
Built-in ASP Objects (2/2)
• Server
– Provides access to methods and
properties on the server
• Session
– Stores information in a session
• ObjectContext
– Transaction management
Request Object
• We use these two collections to
retrieve data submitted in a form
– Request.QueryString - query string in URL,
sent by the GET method
– Request.Form - form elements in the
request body, sent by the POST method
• Request.Cookies is a collection of
cookies sent in the HTTP request
Response Object
• Send output to the browser
• Response.Write “Hello”
• Response.Buffer = true - enable
buffering of the response output
• Response.Flush - flush the buffered
input immediately
Response Object
• Response.Redirect URL - redirect the
browser to another URL
• Response.Expires = n - expires in n
minutes
• Response.End - stop processing of the
ASP file and returns
ASP Session
• Originally, HTTP is stateless
– the browser and the server do not
remember information between web
pages
– difficult to write nontrivial web
application
• Cookies in browser and session
variables in ASP provide a solution
Typical usage of session
• The session starts when a user logs in.
• The session stores the user’s login
information: user name, preferences,
etc and intermediate data in a
transaction (e.g shopping cart)
• The session ends when the user logs
out.
Demo

More Related Content

Similar to Asp #1

Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)Keshab Nath
 
Powering your website with realtime data
Powering your website with realtime dataPowering your website with realtime data
Powering your website with realtime databecoded
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing scienceCharlie Love
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAmin Uddin
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Engine Yard
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrongbostonrb
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrongbostonrb
 
Server side development on java server pages
Server side development on java server pagesServer side development on java server pages
Server side development on java server pagesvinitasharma749430
 
Frames tables forms
Frames tables formsFrames tables forms
Frames tables formsnobel mujuji
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Presentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BPresentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BHapsoro Permana
 

Similar to Asp #1 (20)

Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
Powering your website with realtime data
Powering your website with realtime dataPowering your website with realtime data
Powering your website with realtime data
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing science
 
Advance Sql Server Store procedure Presentation
Advance Sql Server Store procedure PresentationAdvance Sql Server Store procedure Presentation
Advance Sql Server Store procedure Presentation
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
PHP-04-Forms.ppt
PHP-04-Forms.pptPHP-04-Forms.ppt
PHP-04-Forms.ppt
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrong
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrong
 
Java server pages
Java server pagesJava server pages
Java server pages
 
Server side development on java server pages
Server side development on java server pagesServer side development on java server pages
Server side development on java server pages
 
Frames tables forms
Frames tables formsFrames tables forms
Frames tables forms
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
ASP
ASPASP
ASP
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Jsf2.0 -4
Jsf2.0 -4Jsf2.0 -4
Jsf2.0 -4
 
Presentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BPresentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+B
 

More from Joni

ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelJoni
 
.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!Joni
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築Joni
 
Fiddler 使ってますか?
Fiddler 使ってますか?Fiddler 使ってますか?
Fiddler 使ってますか?Joni
 
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Joni
 
ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善Joni
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NETJoni
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationJoni
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to HtmlJoni
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETJoni
 
Asp #2
Asp #2Asp #2
Asp #2Joni
 
ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件Joni
 

More from Joni (13)

ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と ChannelASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
ASP.NET Core の ​ パフォーマンスを支える ​ I/O Pipeline と Channel
 
.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!.NET Framework で ​C# 8って使える? ​YESとNO!
.NET Framework で ​C# 8って使える? ​YESとNO!
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
 
Fiddler 使ってますか?
Fiddler 使ってますか?Fiddler 使ってますか?
Fiddler 使ってますか?
 
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
Fukuoka.NET Conf 2018: 挑み続ける!Dockerコンテナによる ASP.NET Core アプリケーション開発事例
 
ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善ASP.NET パフォーマンス改善
ASP.NET パフォーマンス改善
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NET
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to Html
 
C#
C#C#
C#
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Asp #2
Asp #2Asp #2
Asp #2
 
ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件ASP.NET MVCはNullReferenceExceptionを潰している件
ASP.NET MVCはNullReferenceExceptionを潰している件
 

Recently uploaded

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 

Recently uploaded (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Asp #1

  • 1. Introduction to ASPIntroduction to ASP (Day 1)(Day 1) JoniJoni ATL - Bina NusantaraATL - Bina Nusantara
  • 2. Agenda • ASP • Basic Control Flow – If Then Else – Select Case – For Loop – Do While Loop • Form Processing • Server Side Includes
  • 3. ASP • Active Server Page • The default scripting language is VBScript, but you can use JScript also. • File extension: .asp
  • 4. ASP • Syntax: – to execute some code <% code %> – to print a value <%= variable/expression %> • Variable • if then else, for, while • function / procedure
  • 5. Variable <% option explicit %> <html> <head><title>hello</title></head> <body> <% dim name name = "Peter" dim n n = 18 %> <p>Hello <%= name %>!<br> Your age is <%= n %> </p> </body> </html> ‘option explicit’ enforces variable declaration. ‘option explicit’ enforces variable declaration. By default, you don’t need to declare variables. But for easier debugging, declare every variables. Variables can be string, integer and some other type. By default, you don’t need to declare variables. But for easier debugging, declare every variables. Variables can be string, integer and some other type.
  • 6. ASP using JScript <%@ Language=Jscript %> <html> <head><title>hello</title></head> <body> <% var name = "Peter"; var n = 18; %> <p>Hello <%= name %>!<br> Your age is <%= n %> </p> </body> </html>
  • 7. ASP-Generated HTML <html> <head><title>hello</title></head> <body> <p>Hello Peter!<br> Your age is 18 </p> </body> </html> This is what the browser receives. The browser doesn’t care whether this page is generated by ASP or not. And, it cannot see the ASP source code. This is what the browser receives. The browser doesn’t care whether this page is generated by ASP or not. And, it cannot see the ASP source code.
  • 8. If Then Else <% if strName = “Peter” then %> How are you Peter! <% else if strName = “Mary” then %> Dear Mary! <% else %> How do you do! <%= strName %> <% end if %>
  • 9. Select Case <% select case strName case “Peter” Response.Write(“…”) case “Mary” Response.Write(“…”) case else Response.Write(“…”) end select %>
  • 10. For Loop <table border=“1”> <% for i = 1 to 7 %> <tr> <td><%=i%></td> <td><font size=“<%=i%>”>hello</font> </td> </tr> <% next %> </table>
  • 11. Do While Loop <% dim sum, I i = 1 sum = 0 do while i < 8 sum = sum + I i = i + 1 if sum > 10 then exit do loop %> Exit the do loop immediately Exit the do loop immediately
  • 12. Array <% dim i dim A() redim A(9) for i = 0 to 9 A(i) = i*i next redim preserve A(20) redim A(15) dim B(10,10) %> Array in VBScript is zero-based, i.e. it starts at 0. Dim A(n) wil give an array of size n+1. Array in VBScript is zero-based, i.e. it starts at 0. Dim A(n) wil give an array of size n+1. Resize an array (and preserve the data) Resize an array (and preserve the data) 2D array2D array
  • 13. Form Processing • Use tag <form> … </form> • FORM allows the user to submit data to web server for processing • A FORM contains one or more input fields • After filling the FORM, the user can submit the data usually by pressing a submit button
  • 14. Form Sample <body> <p>Please fill in the form:</p> <form action=“process.asp”> <!-- items goes here --> <input type=“submit” name=“btnSubmit”> </form> </body> URL of an ASP page to process the submitted data URL of an ASP page to process the submitted data
  • 15. Form Components • <input type=“text”> • <input type=“password”> • <input type=“hidden”> • <input type=“radio”> • <input type=“checkbox”> • <input type=“submit”> • <select> <option>…</option> </select> • <textarea> … </textarea>
  • 16. Post Method <body> <p>Please fill in the form:</p> <form action=“process.asp” method=“post”> <!-- items goes here --> <input type=“submit” name=“btnSubmit”> </form> </body> The default method of form is “get”. The data in the form are encoded and transmitted in the body of the HTTP request. They are invisible to the user. The default method of form is “get”. The data in the form are encoded and transmitted in the body of the HTTP request. They are invisible to the user. If we use method “GET”, the form data are attached to the URL submitted to the server. e.g. http://www.test.com/process.asp?name=tom&id=123 If we use method “GET”, the form data are attached to the URL submitted to the server. e.g. http://www.test.com/process.asp?name=tom&id=123
  • 17. GET vs. POST • Encoded form data are attached to the end of the URL in GET method – visible to the end user – can be saved as bookmark – we can use such URL to store pre-filled request • Encoded form data are attached as the request body in POST method – necessary for large amount of form data, e.g. file upload
  • 18. Server Side Includes • <!--#Include file=“header.asp”--> • <!--#Include virtual=“header.asp”-->
  • 19. Built-in ASP Objects (1/2) • Application – Share information among all users of an application • Request – Get information passed in HTTP request, e.g. user input in FORM and file upload • Response – Send information to browser, set cookies, and redirect to another URL
  • 20. Built-in ASP Objects (2/2) • Server – Provides access to methods and properties on the server • Session – Stores information in a session • ObjectContext – Transaction management
  • 21. Request Object • We use these two collections to retrieve data submitted in a form – Request.QueryString - query string in URL, sent by the GET method – Request.Form - form elements in the request body, sent by the POST method • Request.Cookies is a collection of cookies sent in the HTTP request
  • 22. Response Object • Send output to the browser • Response.Write “Hello” • Response.Buffer = true - enable buffering of the response output • Response.Flush - flush the buffered input immediately
  • 23. Response Object • Response.Redirect URL - redirect the browser to another URL • Response.Expires = n - expires in n minutes • Response.End - stop processing of the ASP file and returns
  • 24. ASP Session • Originally, HTTP is stateless – the browser and the server do not remember information between web pages – difficult to write nontrivial web application • Cookies in browser and session variables in ASP provide a solution
  • 25. Typical usage of session • The session starts when a user logs in. • The session stores the user’s login information: user name, preferences, etc and intermediate data in a transaction (e.g shopping cart) • The session ends when the user logs out.
  • 26. Demo