21 – Web applications: Server-side code (ASP)

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
1 Chapter 12 Working With Access 2000 on the Internet.
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.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: HTML and Client-side code.
Servlets and a little bit of Web Services Russell Beale.
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
Mark Dixon, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Introduction to Active Server Pages
Mark Dixon, SoCCE SOFT 131Page 1 16 – Passing Data between pages: Sessions, Query Strings, & Self Posting.
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.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Mark Dixon Page 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
Copyright 2000 eMation SECURITY - Controlling Data Access with
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Mark Dixon 1 18 – Web applications: Server-side code (ASP.Net)
Mark Dixon Page 1 18 – Web applications: Server-side code (ASP)
Mark Dixon Page 1 18 – Web applications: Server-side code (PhP)
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.
HTML Forms.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
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.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Mark Dixon Page 1 15 – Web applications: Server-side code (ASP)
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
CHAPTER 5 SERVER SIDE SCRIPTING
9 – Web applications: Server-side code (ASP)
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
How to Write Web Forms By Mimi Opkins.
18 – Web applications: Server-side code (PhP)
18 – Web applications: Server-side code (ASP)
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Passing variables between pages
12 – Passing Data between pages: Forms, Sessions, & Query Strings
PHP / MySQL Introduction
JSP Implicit Objects Implicit Objects in JSP are objects that are automatically available in JSP. request: The request object retrieves the values that.
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
The Request & Response object
Client side & Server side scripting
Creating Forms on a Web Page
Introduction to JavaScript
A Little Bit of Active Server Pages (ASP)
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Presentation transcript:

21 – Web applications: Server-side code (ASP)

Session Aims & Objectives To introduce the fundamental ideas involved in server-side code Objectives, by end of this week’s sessions, you should be able to: add dynamic server-side functionality, using VB Script

Web Hardware and Software Server Client network connection Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache)

Request-Response Cycle <html> <head> <title>Mark Dixon's web site</title> </head> <body background="BackGround.JPG"> <font size=+3><center><b><p>Mark Dixon's web site</b></center> <font size=+2> <p>Welcome to my web server. Please select from the following list: <ul> <li><a href="./Soft131/Index.htm">Soft131: Introduction to programming for Multimedia and Internet applications.</a> </ul> </font> </body> </html> Response Browser Application (MS Explorer, Netscape) Web-server Application (MS IIS, Apache) http://mdixon.soc.plym.ac.uk/ Request

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

Server-side Script (IIS) IIS / personal web server on Windows CD Start, Settings, Control Panel, Add/Remove Programs Add/Remove Windows Components IIS

Enabling/Disabling IIS Start, Settings, Control Panel, Administrative Tools, Internet Services Manager Start Stop

Server-side Script (how) Date.asp ASP code: .asp (not .htm) between <% and %> Response object: page sent back to client write method: adds text to response object Date() function: current date (server) <html> <head> <title>Today's date</title> </head> <body> <p>The date today is <% Response.Write Date() & "<br>" %> <p>The time is currently Response.Write Time() & "<br>" </body> </html>

Form Submission action attribute submit button Login.htm <html> <head> <title>Login</title> </head> <body> <p>Please login: <form name="frmLogin" action="LoginCheck.asp" method=post> Username:<input name="txtUserName" type="text"><br> Password:<input name="txtPassWord" type="password"><br> <input name="btnLogin" type="submit" value="Login"> </form> </body> </html>

Form Processing LoginCheck.asp <html> <head> <title>Login</title> </head> <body> <% If Request.Form("txtUserName") = "George" Then Response.Write "Login successful." Else Response.Write "Invalid user name." End If %> </body> </html>

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

Code Execution LoginCheck.asp Response Server SW (IIS) <html> <head> <title>Login</title> </head> <body> <% If Request.Form("txtUserName") = "George" Then Response.Write "Login successful." Else Response.Write "Invalid user name." End If %> </body> </html> LoginCheck.asp <html> <head> <title>Login</title> </head> <body> Invalid user name. </body> </html> Response Server SW (IIS)

Maintaining State between pages Problem want to protect all pages from unauthorised access need to store record of successful login Variables only persist for duration of page

Maintaining State (persistent) Cookies (not covered in Soft131) stored on users’ (client) hard drive persists between sessions Database/file (covered in next lecture) stored on server hard drive

Maintaining State (temporary) Forms and Self Posting Query Strings Useful for passing information between pages Session object exists for current session clears if user closes browser clears after 20 mins of inactivity

Maintaining State: Self Posting <http> <head> <title>Multiply</title> <% Dim tmpRes Dim tmpNum1 Dim tmpNum2 If Request.Form("txtNum1") <> "" And Request.Form("txtNum2") <> "" Then tmpNum1 = CDbl(Request.Form("txtNum1")) tmpNum2 = CDbl(Request.Form("txtNum2")) tmpRes = tmpNum1 * tmpNum2 End If %> </head> <body> <form name="frmDefault" action=Multiply.asp method=post> <p><input name=txtNum1 type=text size=5 maxlength=5 value=<%=tmpNum1%>> <input name=txtNum2 type=text size=5 maxlength=5 value=<%=tmpNum2%>> <p><input name=btnCalc type=submit value=Calc> </form> <p><%=tmpRes%> </body> </http> Multiply.asp Only do calc if first load Post to Self

Maintaining State: Query Strings Data can be added to end of URL: http://localhost/page.asp?Surname=Bob ASP code can use this data: Request.QueryString("Surname") would return the value "Bob" Form method=get data automatically added to query string Query String

Example: Date-Time Menu.asp DateTime.asp <html> <head> <body> <p>What background colour do you want for you date information? <br><a href=DateTime.asp?Colour=yellow>Yellow</a> <br><a href=DateTime.asp?Colour=cyan>Light Blue</a> </body> </html> Menu.asp <html> <head> </head> <body bgcolor=<%=request.querystring("Colour")%>> <p>The date is <%=date()%>. <p>The time is <%=time()%>. </body> </html> DateTime.asp

Maintaining State: Session Object Session variable all strings Abandon method deletes all session variables Redirect method redirects browser to specified page <html> <head> <title>Login</title> </head> <body> <% If Request.Form("txtUserName") = "George" Then Session("LoginOK") = "Yes" Response.Redirect "Home.asp" Else Session.Abandon If Request.Form("txtUserName") <> "" Then Response.Write "Invalid user name, please try again." End If %> <p>Please login: <form name="frmLogin" action="Login.asp" method=post> Username:<input name="txtUserName" type="text"><br> Password:<input name="txtPassWord" type="password"><br> <input name="btnLogin" type="submit" value="Login"> </form> </body> </html> Login.asp

Maintaining State: Session Object Home.asp <html> <head> <title></title> <% If Session("LoginOK") <> "Yes" Then Response.Redirect "Login.asp" End If %> </head> <body> <center><b>Home Page</b></center> <p>Welcome to my home page. </body> </html> ASP code to check for successful login

Reference: Server Object Model Request object: calling web page Form: used to get form data from page QueryString: used to get data from address (?) Response object: web page sent back Write: used to put text into web page Redirect: used to navigate to other page Clear: erases all HTML in web page Session object: store data between pages Abandon: clears session data