Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)

Slides:



Advertisements
Similar presentations
Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
Advertisements

Languages for Dynamic Web Documents
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
Server-Side vs. Client-Side Scripting Languages
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
1 Configuring Web services (Week 15, Monday 4/17/2006) © Abdou Illia, Spring 2006.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
Mark Dixon Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Passing Data between pages: Sessions, Query Strings, & Self Posting.
1 Software Testing and Quality Assurance Lecture 32 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 19 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 08 – Web applications: HTML and ActiveX controls.
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Mark Dixon Page 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
ASP.NET Dr. Ralph Westfall May, Web Development Problem HTML designed to display static pages only interactive when user clicks links  can’t provide.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Web Design and Development for E-Business By Jensen J. Zhao Copyright 2003 Prentice Hall, Inc. Web Design and Development for E-Business Jensen J. Zhao.
Mark Dixon 1 18 – Web applications: Server-side code (ASP.Net)
Mark Dixon Page 1 18 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 18 – Web applications: Server-side code (PhP)
Mark Dixon Page 1 21 – Persistent data storage: relational databases and MySQL.
ASP/ASP.NET: Tricks and Tips How to get Microsoft’s Programming Language to work for you By Wade Tripp Park University
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Variables. Mark Dixon, SoCCE SOFT 131Page 2 Admin: Test (next week) In class test –teaching week 6 –university week.
Mark Dixon Page 1 Web-Application Development Workshop.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Mark Dixon Page 1 03 – Dynamic HTML (client-side scripting)
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon 1 03 – Information Processing. Mark Dixon 2 Questions: Events Consider the following code: a) How many unique events does it contain? b) Name.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Datatypes and Object Association.
M Dixon 1 Web-Application Development Workshop. M Dixon 2 Session Aims & Objectives Aims –to introduce the main concepts involved in creating web-applications.
Mark Dixon 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
M Dixon 1 Tech HTML. M Dixon 2 Admin Attendance Register: –log in to your profile.
Mark Dixon Page 1 Tech – HTML. Mark Dixon Page 2 Admin Attendance Register: –log in to your profile.
Mark Dixon 1 9 – Case Study. Mark Dixon 2 Session Aims and Objectives Aims –To give an overview of the development of a web-page from initial idea to.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
PHP Form Processing * referenced from
IST 210: PHP Basics IST 210: Organization of Data IST2101.
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
9 – Web applications: Server-side code (ASP)
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
Introduction to ASP By “FlyingBono” 2009_01 By FlyingBono 2009_01
21 – Web applications: Server-side code (ASP)
18 – Web applications: Server-side code (PhP)
18 – Web applications: Server-side code (ASP)
12 – Passing Data between pages: Forms, Sessions, & Query Strings
WEB PROGRAMMING JavaScript.
17 – Persistent data storage: relational databases and ADO
Introduction to JavaScript
Presentation transcript:

Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)

Mark Dixon Page 2 Session Aims & Objectives Aims –To introduce the fundamental ideas involved in server-side code Objectives, by end of this week’s sessions, you should be able to: –create an asp web-page, including: HTML, and server-side VB script

Mark Dixon Page 3 Example: Logon (analysis) SPECIFICATION User Requirements –protection from fraud and invasion of privacy Software Requirements –Functional: –logon page, user must type name and password –following pages can only be accessed after successful logon –Non-functional should be very difficult to hack hotmail, Amazon, University portal, utility bills (gas, electricity, phone, internet), Travel (flights, ferry, car rental)

Mark Dixon Page 4 Example: Logon (design) Restrict access to home page

Mark Dixon Page 5 Example: Logon (code v1) Using Client-side VB Script Please logon: Sub btnLogon_OnClick() Dim un Dim pw un = txtUserName.value pw = txtPassWord.value If un = "mark" And pw = "soft131" Then window.navigate "home.htm" Else msg.innerText = "Login details incorrect." End If End Sub Logon.htm My Home page Welcome to my home page. Home.htm

Mark Dixon Page 6 Example: Login (Problem) View Source – shows client-side script: Reveals both username & password

Mark Dixon Page 7 network connection Web Hardware and Software Client Server Browser Application (MS Explorer, FireFox, Opera) Web-server Application (MS IIS, Apache)

Mark Dixon Page 8 Browser Application (MS Explorer, Firefox) Request-Response Cycle Web-server Application (MS IIS, Apache) Logon.htm Request Please logon: Sub btnLogon_OnClick() Dim un Dim pw un = txtUserName.value pw = txtPassWord.value If un = "mark" And pw = "soft131" Then window.navigate "home.htm" Else msg.innerText = "Login details incorrect." End If End Sub Response Client-side code: Code sent to Client Interpreted by browser

Mark Dixon Page 9 Server-side Script (what) ASP – active server pages –code not sent to client code secure (can't be viewed by client) –executed on server takes time – request-response cycle requires server software (e.g. IIS) ASP pages will NOT work by double clicking on file

Mark Dixon Page 10 Example: Date ASP code: –.aspx (not.htm) –VB (not vbscript) –variables have type –Now is current date and time (on server) –runat="server" gives server code access to object Sub Page_Load () Dim s As String s = "The date today is " s = s & Format(Now, "ddd d MMM yyyy") parD.InnerText = s s = "The time now is " s = s & Format( Now, "HH:mm") parT.InnerText = s End Sub Today's Date Date.aspx

Mark Dixon Page 11 Request-Response Cycle Browser Application (MS Explorer, Firefox) Web-server Application (MS IIS, Apache) date.aspx Request Today's Date The date today is Mon 9 Feb 2009 The time now is 00:57 Response Sub Page_Load() Dim s As String s = "The date today is " s = s & Format(Now, "ddd d MMM yyyy") parD.InnerText = s s = "The time now is " s = s & Format(Now, "HH:mm") parT.InnerText = s End Sub Today's Date Server-side code: run on server (never sent to Client)

Mark Dixon Page 12 View Source Code executed at server –code is never sent to client View, Source – does not show code:

Mark Dixon Page 13 Data Types Variant – all types of data –slow, memory hungry Boolean – true or false (on/off, yes/no) Integer – whole numbers ( to 32768) Long – whole numbers (large) Single – decimal numbers Double – decimal numbers (more precise) String – text Object – object instances

Mark Dixon Page 14 Data Type Selection Number ofe.g. 4 Integer/Long Rooms Heighte.g. 1.87m Single/Double Surnamee.g. Smith String Car Rege.g. XY55 ABC String

Mark Dixon Page 15 Using data types Variable declaration Dim x As Long Parameters Sub Thing(boo As String, y As Long) Functions Function IsTall() As Boolean

Mark Dixon Page 16 Question: Data types Declare a variable to store: –an animal's weight in kg (e.g. 34.6) –whether a person has a driving licence or not –the title of a book –a phone number (e.g ) Dim weight As Double Dim licence As Boolean Dim title As String Dim phone As String

Mark Dixon Page 17 Example: AddNum (client-side) Sub btnAdd_onClick() Dim N1 Dim N2 N1 = txtN1.Value N2 = txtN2.Value parRes.InnerText = N1 + CDbl(N2) End Sub AddNum.htm

Mark Dixon Page 18 Example: AddNum (server-side) input tags inside form submit button: refreshes page (sending data to server) Sub Page_Load() Dim N1 As Double Dim N2 As Double If Request.Form("btnAdd") > "" Then N1 = txtN1.Value N2 = txtN2.Value parRes.InnerText = N1 + N2 End If End Sub AddNum.aspx If btnAdd clicked

Mark Dixon Page 19 Sub Page_Load () Dim N1 As Double Dim N2 As Double If Request.Form("btnAdd") > "" Then N1 = txtN1.Value N2 = txtN2.Value parRes.InnerText = N1 + N2 End If End Sub AddNum.aspx Sub btnAdd_onClick () Dim N1 Dim N2 N1 = txtN1.Value N2 = txtN2.Value parRes.InnerText = N1 + CDbl (N2) End Sub AddNum.htm Client-side vs. Server-side Code Both use VB Script language (i.e. Sub, If, Dim, For, etc.)

Mark Dixon Page 20 Example: Apples Sub Page_Load() If Request.Form("btnGo") > "" Then parRes.InnerHtml = parRes.InnerHtml & " " End If End Sub Apples Apples.aspx

Mark Dixon Page 21 Errors Sub Page_Load() Dim s As String s = "The date today is " s = s & Format(Now, "ddd d MMM yyyy") parD.InnerText = s s = "The time now is " s = s & Format(Now, "HH:mm") parT.InnerText = s End Sub parD.innerText = "" Today's Date vbscript cannot run at server (should be VB) parT is undefined (should have runat="server") Declaration expected (assignment must be in sub)

Mark Dixon Page 22 Running your ASP pages within Visual Studio –Run (play) button (F5) –only available to you on development PC using Internet Information Services (IIS) –makes PC a server –page available to all computers on internet

Mark Dixon Page 23 IIS - Installing IIS / personal web server on Windows CD Start, Settings, Control Panel, Add/Remove Programs Add/Remove Windows Components IIS

Mark Dixon Page 24 IIS: Enabling/Disabling Start, Settings, Control Panel, Administrative Tools, Internet Services Manager Stop Start

Mark Dixon Page 25 IIS: Exposing pages Put ASP pages in: –C:\INetPub\wwwRoot (this part of hard disk exposed to outside world) Execute pages by putting: –localhost (in web browser, e.g. IE, means local machine) ASP pages don't work by double-clicking

Mark Dixon Page 26 IIS – Date.asp localhost/test/date.aspx C:\INetPub\wwwRoot\Date.aspx

Mark Dixon Page 27 Tutorial Exercise: Login (client-side) LEARNING OBJECTIVE: see how vulnerable client-side code is Task 1: Get the Login (v1) example from the lecture working. Task 2: Use view source – you should be able to see the code.

Mark Dixon Page 28 Tutorial Exercise: Date LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script Task 1: Get the Date example from the lecture working. Task 2: Add code that displays good morning/afternoon/evening/night, depending on the time of day.

Mark Dixon Page 29 Tutorial Exercise: Student Loan LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script from scratch to solve a problem Task 1: Create a web page that allows the user to enter their salary and the computer calculates the annual and monthly payments for their student loan. Hint: Use your client-side code (from term 1), and the AddNum example from the lecture.

Mark Dixon Page 30 Tutorial Exercise: Login (client-side) LEARNING OBJECTIVE: create an ASP page, including HTML and server-side VB Script from scratch to solve a problem Task 1: Create a login page that uses server-side code to check the username and password entered by the user. Hint: Use the AddNum example as inspiration. Hint2: Use the following code to send the user to the homepage: Response.Redirect("Home.htm") Task 2: Use view source – you should NOT be able to see the code.

Mark Dixon Page 31 Tutorial Exercise: Apples LEARNING OBJECTIVE: use variables with specific data types in ASP code Task 1: Get the apples example (from the lecture) working. Task 2: Modify your program so that the user enters a number, and the code adds that number of apple images. Task 3: Modify your program so that the user enters another number, and the code adds a new line tag for that number of apples. Hint: Within the loop divide the number of apples by the second number, if the result is a whole number add a new line tag.