Presentation is loading. Please wait.

Presentation is loading. Please wait.

2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 1 Dynamic HTML Using Active Server Pages (ASP) Alberto Espinosa MIS 45-870.

Similar presentations


Presentation on theme: "2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 1 Dynamic HTML Using Active Server Pages (ASP) Alberto Espinosa MIS 45-870."— Presentation transcript:

1 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 1 Dynamic HTML Using Active Server Pages (ASP) Alberto Espinosa MIS 45-870

2 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 2 Static HTML and the HTTP Protocol HTTP  designed as a doc fetching protocol: 1. User clicks on URL with HTTP protocol 2. Browser requests HTML page to web site 3. Server finds/sends HTML page to client “as is” 4. Client’s browser interprets HTML and presents page to user

3 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 3 Dynamic HTML Overcoming HTTP Shortcomings HTML is static: text (info) and tags (formatting) Corporate information is dynamic If info changes  HTML pages need to change How to customize displays for different users?

4 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 4 Dynamic HTML 2 Solutions to Static HTML 1. Client side scripting Further processing by browser after page is received 2. Server side scripting Prior processing by web server before page is sent

5 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 5 Client Side Scripting Useful for interactive use with user Browser needs to support the scripting language used Most popular: JavaScript, VB Script Embed scripts in HTML page HTML stuff script code ………… More HTML stuff

6 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 6 Server Side Scripting Useful to interact with data stored on the server (databases, images, etc.) And when centralized processing is needed Sever needs to support the scripting language Most popular: CGI  Perl (Unix) ASP  VB Script or JScript (Windows)

7 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 7 Server Side Scripting (cont’d) Embedded scripts in HTML page HTML code <% (marks the beginning of ASP script) ………..………. ASP script code ……………….... %> (marks the end of ASP script) More HTML code Etc.

8 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 8 Dynamic HTML with ASP 1. Client clicks on URL with.asp file 2. Web server notices file extension.asp Note: Only Windows NT IIS web server supports ASP 3. Server then processes.asp file 4. Server creates a new HTML file 5. Contains all original HTML stuff 6. Plus processing results from ASP code 7. Dynamically formatted as HTML 8. Server sends the new HTML file to client

9 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 9 Dynamic HTML with ASP Welcome to my page Here is my product list <% ‘Start ASP code Open a database connection SQL queries to database Copy results to a record set Display records one at a time Close database connection %> ‘End ASP code Thank you very much for inquiring about our products Welcome to my page Here is my product list Product Price Hammer ……... $8.50 Pliers ……….… $7.79 Screwdriver..… $4.50 Power Drill ….. $49.99 Chainsaw …… $95.95 Wrench ……….. $6.50 Thank you very much for inquiring about our products ASP code on serverHTML code sent to client Same Dynamically generated by ASP

10 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 10 ASP, SQL, Databases, and HTML Web Server MS IIS Web Server Client Browser Internet Explorer Netscape Navigator HTML ASP Databases HTML Request HTML doc Fetched ASP Request SQL Query Query Results Dynamic HTML Produced On-the-Fly

11 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 11 Server Requirements You can’t do ASP on Andrew ASP requires an MS Windows environment –NT Server with Internet Information Server –NT Workstation with “Peer Web Services” (10-user connection limit) –Win95/98 with Personal Web Server

12 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 12 Common Uses of ASP Register as a client (insert a record in database) Products & services listing (query database) Place orders (inserting records in database) Track order status (query database) Tech support (query a knowledge base) Fill out a survey (insert record(s) in database)

13 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 13 Very Common Feed data to an ASP script using HTML forms This is typically what the “Submit” button does HTML forms contain items data with field names Which are passed to ASP scripts for processing Often used to embed an SQL command To query a database (product list, etc.) Or to insert records in a database (orders, etc.)

14 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 14 Example--ASP on Server (Query) <% Set conn = Server.CreateObject("ADODB.Connection") conn.open "orders " Set rs_customers = Conn.Execute("SELECT clientID, clientName,_ shipAddress, telephone FROM clients") %> Alberto's Music Instruments, Inc. Customer List ClientID Client Name Shipping Address Telephone <% rs_customers.MoveNext loop Conn.Close %>

15 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 15 Example--Response to Browser Alberto's Music Instruments, Inc. Customer List ClientID Client Name Shipping Address Telephone josee Alberto Espinosa Schenley Park, GSIA Building, #20 412-268-3681 sandy Sandra Slaughter 5000 Forbes Avenue, Pittsburgh PA 15213 412-268-3681 etc.

16 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 16 Example--ASP on Server (Data Input) Customer Registration <FORM ACTION= "http://softrade-11.gsia.cmu.edu/data/customerSubmit.asp" METHOD="POST" ENCTYPE="x-www-form-urlencoded"> Please enter a customer ID (4 to 16 characters) Please enter your name etc.

17 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 17 Example--ASP on Server (Data Input) <% Set conn = Server.CreateObject("ADODB.Connection") conn.open "orders” customerId = Request.Form("customerId") custName = Request.Form("custName") …. etc. Set rs = Conn.Execute("INSERT INTO Clients (ClientID, CustName, _ etc. VALUES ('" & customerID & "', '" & customerName & "', _ '" & shippingAddress & "', '" & phone & "') ") Conn.Close %> Your Customer Registration has been processed! Thank you very much Back to main page

18 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 18

19 2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 19 IT Exercise III A restaurant food delivery service company Participant restaurants subscribe to service Company developed a web site using ASP to let: 1. Restaurants subscribe and enter menu items 2. Customers place orders Web server runs on Windows NT with IIS Participant restaurants need to produce their HTML pages with order forms Which don’t need to run on IIS (nor ASP) But need to feed data to existing ASP scripts


Download ppt "2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 45-870 1 Dynamic HTML Using Active Server Pages (ASP) Alberto Espinosa MIS 45-870."

Similar presentations


Ads by Google