15 Chapter 15 Web Databases Hachim Haddouti. 15 2 Hachim Haddouti and Rob & Coronel, Ch15 In this chapter, you will learn: Briefly Internet Concepts (HTML,

Slides:



Advertisements
Similar presentations
Overview Environment for Internet database connectivity
Advertisements

Chapters 14 & 15 Internet Databases. E-Commerce  Bringing new products, services, or ideas to market, supporting and enhancing business operations 
Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
1 Chapter 12 Working With Access 2000 on the Internet.
Chapter Concepts Review Markup Languages
Servlets and a little bit of Web Services Russell Beale.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
INTERNET DATABASE Chapter 9. u Basics of Internet, Web, HTTP, HTML, URLs. u Advantages and disadvantages of Web as a database platform. u Approaches for.
Introduction to Web Database Processing
Introduction to Web Application Architectures Web Application Architectures 18 th March 2005 Bogdan L. Vrusias
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Introduction to Web Interface Technology (CSE2030)
12 Chapter 12 Client/Server Systems Hachim Haddouti.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Introduction to Web Interface Technology (CSE2030)
Chapter 14 Database Connectivity and Web Technologies
14 Chapter 14 Databases and The Internet Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Internet Applications Chapter 7 Modified by Donghui Zhang.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Server-side Technologies
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
1 Internet Applications Chapter 7, Sections 7.6—7.8.
Databases and the Internet. Lecture Objectives Databases and the Internet Characteristics and Benefits of Internet Server-Side vs. Client-Side Special.
Week 7 Lecture Web Database Development Samuel Conn, Asst. Professor
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
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.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
11/16/2012ISC329 Isabelle Bichindaritz1 Web Database Application Development.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Fundamentals of Database Chapter 7 Database Technologies.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
2-1 WEB DATABSE INTERFACING Colorado Technical University IT420.
Chapter 6 Server-side Programming: Java Servlets
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 14 Database Connectivity and Web Technologies.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Java Servlets and Java Server Pages Norman White Stern School of Business.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
14 1 Chapter 14 Web Database Development Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
WEB SERVER SOFTWARE FEATURE SETS
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.
Database Connectivity and Server-Side Scripting Chapter 12.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 14 Database Connectivity and Web Technologies.
Java Servlets and Java Server Pages
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
National College of Science & Information Technology.
Internet Applications
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Presentation transcript:

15 Chapter 15 Web Databases Hachim Haddouti

15 2 Hachim Haddouti and Rob & Coronel, Ch15 In this chapter, you will learn: Briefly Internet Concepts (HTML, HTTP, Get, Post, CSS, XML, XSLT, JavaScript) The architecture of Web-to-database middleware Middle tier: CGI, application servers, Servlets, JSP, ASP, passing arguments, maintaining state (cookies)

15 3 Hachim Haddouti and Rob & Coronel, Ch15 Overview of the Presentation Tier Recall: Functionality of the presentation tier –Primary interface to the user –Needs to adapt to different display devices (PC, PDA, cell phone, voice access?) –Simple functionality, such as field validity checking We will cover: –HTML Forms: How to pass data to the middle tier –JavaScript: Simple functionality at the presentation tier –Style sheets: Separating data from formatting

15 4 Hachim Haddouti and Rob & Coronel, Ch15 HTML Forms Common way to communicate data from client to middle tier General format of a form: – … Components of an HTML FORM tag: –ACTION: Specifies URI that handles the content –METHOD: Specifies HTTP GET or POST method –NAME: Name of the form; can be used in client-side scripts to refer to the form

15 5 Hachim Haddouti and Rob & Coronel, Ch15 Inside HTML Forms INPUT tag –Attributes: TYPE: text (text input field), password (text input field where input is, reset (resets all input fields) NAME: symbolic name, used to identify field value at the middle tier VALUE: default value –Example: Example form:

15 6 Hachim Haddouti and Rob & Coronel, Ch15 Passing Arguments Two methods: GET and POST GET (The GET method appends name/value pairs to the URL) –Form contents go into the submitted URI –Structure: action?name1=value1&name2=value2&name3=value3 Action: name of the URI specified in the form (name,value)-pairs come from INPUT fields in the form; empty fields have empty values (“name=“) –Example from previous password form: TableOfContents.jsp?userid=john&password=johnpw –Note that the page named action needs to be a program, script, or page that will process the user input

15 7 Hachim Haddouti and Rob & Coronel, Ch15 POST –packages the name/value pairs inside the body of the HTTP request 1.Query length can be unlimited (unlike in GET) 2.Is used to send a chunk of data to the server to be processed 3.You can send entire files using post 4.Your form data is attached to the end of the POST request (as opposed to the URL) 5.Not as quick and easy as using GET, but more versatile (provided that you are writing the CGI directly)

15 8 Hachim Haddouti and Rob & Coronel, Ch15 HTML Forms: A Complete Example Userid Password <input type="submit" value="Login“ name="submit">

15 9 Hachim Haddouti and Rob & Coronel, Ch15 JavaScript Goal: Add functionality to the presentation tier. Sample applications: –Detect browser type and load browser-specific page –Form validation: Validate form input fields –Browser control: Open new windows, close existing windows (example: pop-up ads) Usually embedded directly inside the HTML with the … tag. tag has several attributes: –LANGUAGE: specifies language of the script (such as javascript) –SRC: external file with script code –Example:

15 10 Hachim Haddouti and Rob & Coronel, Ch15 JavaScript: A Complete Example HTML Form: <form method="POST“ action="TableOfContents.jsp"> Associated JavaScript: function testLoginEmpty() { loginForm = document.LoginForm if ((loginForm.userid.value == "") || (loginForm.password.value == "")) { alert('Please enter values for userid and password.'); return false; } else return true; }

15 11 Hachim Haddouti and Rob & Coronel, Ch15 Stylesheets Idea: Separate display from contents, and adapt display to different presentation formats Two aspects: –Document transformations to decide what parts of the document to display in what order –Document rending to decide how each part of the document is displayed Why use stylesheets? –Reuse of the same document for different displays –Tailor display to user’s preferences –Reuse of the same document in different contexts Two stylesheet languages –Cascading style sheets (CSS): For HTML documents –Extensible stylesheet language (XSL): For XML documents

15 12 Hachim Haddouti and Rob & Coronel, Ch15 Evolution to XML Concept of markup langauge

15 13 Hachim Haddouti and Rob & Coronel, Ch15 XML HTML is Layout desciption language - XML not!!! Tags such Font or CENTRE are not necessary in XML. XML uses structured Tags, such as TITLE, CHAPTER, etc.  document structure remains constant over different media. XSL: XML Style Sheet Language, between CSS (Cascading Style Sheets) and DSSSL (Document Style Semantics and Specification Language) XML: Content and Layout are separted XSL: a document can have more XSL representations XSL allows a conversion of XML documents in HTML

15 14 Hachim Haddouti and Rob & Coronel, Ch15 Logical Structure of XML Comments Notations Prolog Elements Attributes CDATA DTD (Document Type Definition): grammar for the logical structure of an XML document (validation) New: XML Schema is a language for describing and constraining the content of XML documents. More about XML see or Hello World, please stop the planet, I want to get off! <!DOCTYPE greeting [ ]>

15 Hachim Haddouti and Rob & Coronel, Ch15 Web Database Connectivity Allows rapid response to competitive pressures –New services –New products Customer support enhanced Fast effective information dissemination –Universal access –Local –Around the globe

15 16 Hachim Haddouti and Rob & Coronel, Ch15 Typical Uses of Internet

15 17 Hachim Haddouti and Rob & Coronel, Ch15 Characteristics/Benefits of Internet Technology Hardware & software independence –Cost savings –Uses existing equipment –Platform independence and portability –No need for multiple platform development Common simple user interface –Reduced training –Reduced support

15 18 Hachim Haddouti and Rob & Coronel, Ch15 Characteristics/Benefits of Internet Technology (con’t.) Location Independence –Global access through Internet –Reduced costs for dedicated connections Rapid development at manageable costs –Development tools –Low entry costs –Available software & access tools

15 19 Hachim Haddouti and Rob & Coronel, Ch15 Web-to-Database Middleware Server-side extension –Interacts directly with Web server –Handles specific requests –Also known as Web-to-database middleware –Examples CGI API (JSP, ASP) Client-site: applet, activeX, VBscript

15 20 Hachim Haddouti and Rob & Coronel, Ch15 Web-to-Database Middleware

15 21 Hachim Haddouti and Rob & Coronel, Ch15 Web Server Interfaces Common Gateway Interface (CGI) –Uses script files to connect to database –Perl, C++, VB, PHP Application Programming Interface (API) –Newer and more efficient –Uses DLLs –Memory resident and faster –Well known APIs Netscape (NSAPI) Internet Server API from Microsoft (ISAPI) WebSite API from O’Reilly (WSAPI)

15 22 Hachim Haddouti and Rob & Coronel, Ch15 API and CGI Web Server Interfaces

15 23 Hachim Haddouti and Rob & Coronel, Ch15 CGI: Common Gateway Interface Goal: Transmit arguments from HTML forms to application programs running at the middle tier Details of the actual CGI protocol unimportant  libraries implement high-level interfaces Disadvantages: –The application program is invoked in a new process at every invocation (remedy: FastCGI) –No resource sharing between application programs (e.g., database connections) –Remedy: Application servers

15 24 Hachim Haddouti and Rob & Coronel, Ch15 CGI: Example HTML form: Type an author name: Perl code: use CGI; $dataIn=new CGI; $dataIn->header(); $authorName=$dataIn->param(‘authorName’); print(“ Argument passing test ”); print(“The author name is “ + $authorName); print(“ ”); exit;

15 25 Hachim Haddouti and Rob & Coronel, Ch15 Web-to-Database Middleware Connection Methods Native SQL access middleware Use services of Open Database Connectivity (ODBC) Use Object Linking and Embedding Database (OLE DB) interface with Windows ODBC most common

15 26 Hachim Haddouti and Rob & Coronel, Ch15 ODBC to Access Databases Figure 15.3

15 27 Hachim Haddouti and Rob & Coronel, Ch15 Web-to-Database Middleware Uses ODBC to Access Databases

15 28 Hachim Haddouti and Rob & Coronel, Ch15 Application Server: Process Structure Process Structure Web BrowserWeb Server Application Server C++ Application JavaBeans DBMS 1 DBMS 2 Pool of Servlets HTTP JDBC ODBC

15 29 Hachim Haddouti and Rob & Coronel, Ch15 Servlets Java Servlets: Java code that runs on the middle tier –Platform independent –Complete Java API available, including JDBC –can execute more quickly than CGI applications (threads instead of invoking processes)  the amount of system overhead for each request is slight. Example: import java.io.*; import java.servlet.*; import java.servlet.http.*; public class ServetTemplate extends HttpServlet { public void doGet(HTTPServletRequest request, HTTPServletResponse response) throws SerletExpection, IOException { PrintWriter out=response.getWriter(); out.println(“Hello World”); }

15 30 Hachim Haddouti and Rob & Coronel, Ch15 Servlets (Contd.) Life of a servlet? –Webserver forwards request to servlet container –Container creates servlet instance (calls init() method; deallocation time: calls destroy() method) –Container calls service() method service() calls doGet() for HTTP GET or doPost() for HTTP POST Usually, don’t override service(), but override doGet() and doPost()

15 31 Hachim Haddouti and Rob & Coronel, Ch15 Servlets: A Complete Example public class ReadUserName extends HttpServlet { public void doGet(HttpServletRequest request, HttpSevletResponse response) throws ServletException, IOException { reponse.setContentType(“text/html”); PrintWriter out=response.getWriter(); out.println(“ \n \n” + “ ” + request.getParameter(“userid”) + “\n” + “ ” + request.getParameter(“password”) + “\n” + “ \n ”); } public void doPost(HttpServletRequest request, HttpSevletResponse response) throws ServletException, IOException { doGet(request,response); }

15 32 Hachim Haddouti and Rob & Coronel, Ch15 JavaBeans JavaBeans is an object-oriented programming interface from Sun Microsystems that lets you build re-useable applications or program building blocks called componentsobject-oriented programmingcomponent These components or Beans can be deployed in a network on any major operating system platform. Like Java applet, JavaBeans components (or "Beans") can be used to give World Wide Web pages (or other applications) interactive capabilities such as computing interest rates or varying page content based on user or browser characteristics,JavaappletBeanbrowser can be run on any major operating system platform (Windows 95, UNIX, Mac) inside a number of application environments (known as containers), Beans also have persistence, which is a mechanism for storing the state of a component in a safe place. This would allow, for example, a component (bean) to "remember" data that a particular user had already entered in an earlier user session.

15 33 Hachim Haddouti and Rob & Coronel, Ch15 Java Server Pages Servlets –Generate HTML by writing it to the “PrintWriter” object –Code first, webpage second JavaServerPages –Written in HTML, Servlet-like code embedded in the HTML –Webpage first, code second –They are usually compiled into a Servlet

15 34 Hachim Haddouti and Rob & Coronel, Ch15 JavaServerPages: Example Welcome to B&N Welcome back! <% String name=“NewUser”; if (request.getParameter(“username”) != null) { name=request.getParameter(“username”); } %> You are logged on as user

15 35 Hachim Haddouti and Rob & Coronel, Ch15 <% ' Declare our variables! Dim cnnSimple ' ADO connection Dim rstSimple ' ADO recordset Dim strDBPath ' path to our database (*.mdb) file ' MapPath of virtual database file path to a physical path. ' If you want you could hard code a physical path here. strDBPath = Server.MapPath("db_scratch.mdb") ' Create an ADO Connection to connect to the scratch database. ' We're using OLE DB but you could just as easily use ODBC. Set cnnSimple = Server.CreateObject("ADODB.Connection") ' This line is for the Access sample database: 'cnnSimple.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";“ ' We're actually using SQL Server so we use this line instead: cnnSimple.Open "Provider=SQLOLEDB;Data Source= ;" _ & "Initial Catalog=samples;User Id=samples;Password=password;" _ & "Connect Timeout=15;Network Library=dbmssocn;" ' Execute a query using the connection object. It automatically ' creates and returns a recordset which we store in our variable. Set rstSimple = cnnSimple.Execute("SELECT * FROM scratch") ASP Example

15 36 Hachim Haddouti and Rob & Coronel, Ch15 ' Display a table of the data in the recordset. We loop through the ' recordset displaying the fields from the table and using MoveNext ' to increment to the next record. We stop when we reach EOF. %> <% Do While Not rstSimple.EOF %> <% rstSimple.MoveNext Loop %> <% 'Close our recordset and connection and dispose of the objects rstSimple.Close Set rstSimple = Nothing cnnSimple.Close Set cnnSimple = Nothing ' That's all folks! %>

15 37 Hachim Haddouti and Rob & Coronel, Ch15 ASP Script Result Tuesday154/15/2003 4:18:22 AM Tuesday224/15/2003 4:00:53 AM Tuesday154/15/2003 4:01:59 AM Tuesday154/15/2003 4:06:59 AM Tuesday154/15/2003 4:07:45 AM Tuesday154/15/2003 4:18:42 AM Tuesday154/15/2003 4:23:15 AM Tuesday154/15/2003 4:23:26 AM Tuesday154/15/2003 4:24:42 AM Tuesday154/15/2003 4:40:56 AM

15 38 Hachim Haddouti and Rob & Coronel, Ch15 Welcome Mr. ID= Gpa <% ASP Example: Insert

15 39 Hachim Haddouti and Rob & Coronel, Ch15 dim sql_query, id, name, gpa ID = Request.Form("id") name = Request.Form("name") gpa = Request.Form("gpa") sql_query = "insert into student_table values('"&id& "', '"& name & "', '" & gpa & "')" set my_conn = server.CreateObject("ADODB.Connection") set my_comm = server.CreateObject("ADODB.Command") my_conn.Open "DRIVER=SQL Server;SERVER=sseserver;UID=csc_3326_guest_admin;APP=Microsoft Development Environment;WSID=RABID;DATABASE=student", "sa", "" my_comm.ActiveConnection = my_conn my_comm.CommandText = sql_query my_comm.Execute Response.Write "OK" %> ASP Example: Insert (cont.)

15 40 Hachim Haddouti and Rob & Coronel, Ch15 HTML> Name: id: gpa: Example: HTML FORM for inserting

15 41 Hachim Haddouti and Rob & Coronel, Ch15 Maintaining State HTTP is stateless. Advantages –Easy to use: don’t need anything –Great for static-information applications –Requires no extra memory space Disadvantages –No record of previous requests means No shopping baskets No user logins No custom or dynamic content Security is more difficult to implement

15 42 Hachim Haddouti and Rob & Coronel, Ch15 Application State Server-side state –Information is stored in a database, or in the application layer’s local memory Client-side state –Information is stored on the client’s computer in the form of a cookie Hidden state –Information is hidden within dynamically created web pages

15 43 Hachim Haddouti and Rob & Coronel, Ch15 Application State So many kinds of state… …how will I choose?

15 44 Hachim Haddouti and Rob & Coronel, Ch15 Server-Side State Many types of Server side state: 1. Store information in a database –Data will be safe in the database –BUT: requires a database access to query or update the information 2. Use application layer’s local memory –Can map the user’s IP address to some state –BUT: this information is volatile and takes up lots of server main memory 5 million IPs = 20 MB

15 45 Hachim Haddouti and Rob & Coronel, Ch15 Server-Side State Should use Server-side state maintenance for information that needs to persist –Old customer orders –“Click trails” of a user’s movement through a site –Permanent choices a user makes

15 46 Hachim Haddouti and Rob & Coronel, Ch15 Client-side State: Cookies Storing text on the client which will be passed to the application with every HTTP request. –Can be disabled by the client. –Are wrongfully perceived as "dangerous", and therefore will scare away potential site visitors if asked to enable cookies 1 Are a collection of (Name, Value) pairs 1

15 47 Hachim Haddouti and Rob & Coronel, Ch15 Internet Database: Special Considerations Involve more than just database-enabled Web applications Issues important to corporate databases –Data security –Transaction management –Client-side data validation –Operational and management challenges Database applications development most affected by Internet

15 48 Hachim Haddouti and Rob & Coronel, Ch15 Supported Data Types Integrated data from multiple sources –Word-processor documents –Pictures –Sounds –Movies Methods for storing and extracting data objects Overhead created by storage Client browser support of object being accessed Size of database considering multimedia and other data

15 49 Hachim Haddouti and Rob & Coronel, Ch15 Data Security Web Server Level –Secure transactions using encryption –TCP/IP protocol level –Firewalls RMDBS Vendors –Login authentication –Restrict access to particular SQL commands Web-to-database middleware –End user restrictions –Designer created algorithms Must support e-commerce applications

15 50 Hachim Haddouti and Rob & Coronel, Ch15 Transaction Management Concept is foreign to Web Dilemma created by request-reply model –Web cannot maintain open line between client and database –Recovery requires client maintain open communications Designers must ensure proper transaction management support at database server level ColdFusion uses CFTRANSACTION tag for transaction management support

15 51 Hachim Haddouti and Rob & Coronel, Ch15 Application Servers Idea: Avoid the overhead of CGI –Main pool of threads of processes –Manage connections –Enable access to heterogeneous data sources –Other functionality such as APIs for session management Commercial Application Server –Bea WebLogic –WebSphere

15 52 Hachim Haddouti and Rob & Coronel, Ch15 Summary We covered: Internet Concepts (URIs, HTTP) Web data formats –HTML, XML, DTDs The presentation layer –HTML forms; HTTP Get and POST, URL encoding; Javascript; Stylesheets. XSLT The middle tier –CGI, application servers, Servlets, JavaServerPages, ASPs, passing arguments, maintaining state (cookies)