2/22/00J. Alberto Espinosa -- CMU/GSIA MIS Dynamic HTML Using Active Server Pages (ASP) Alberto Espinosa MIS
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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?
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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)
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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.
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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)
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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.)
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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 %>
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS Example--Response to Browser Alberto's Music Instruments, Inc. Customer List ClientID Client Name Shipping Address Telephone josee Alberto Espinosa Schenley Park, GSIA Building, # sandy Sandra Slaughter 5000 Forbes Avenue, Pittsburgh PA etc.
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS Example--ASP on Server (Data Input) Customer Registration <FORM ACTION= " METHOD="POST" ENCTYPE="x-www-form-urlencoded"> Please enter a customer ID (4 to 16 characters) Please enter your name etc.
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS
2/22/00J. Alberto Espinosa -- CMU/GSIA MIS 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