ICOM 5016 Database Systems. Database Users. User Interfaces and Tools. Chapter 8: Application Design and Development.

Similar documents
Chapter 8: Application Design and Development

User Interfaces and Tools. Web Interfaces to Database (Cont.) Web Interfaces to Databases. Client Side Scripting and Applets.

Chapter 21: Application Development and Administration

Chapter 21: Application Development and Administration

Chapter 21: Application Development and Administration

Database Application Development

Chapter 9: Application Design and Development

13. Databases on the Web

Enterprise Java Unit 1- Chapter 3 Prof. Sujata Rizal Introduction to Servlets

Introduction. This course Software Architecture with Java will discuss the following topics:

Database Applications

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Chapter 10 Web-based Information Systems

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

Web based Applications, Tomcat and Servlets - Lab 3 -

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

SSC - Web applications and development Introduction and Java Servlet (I)

Ch04 JavaServer Pages (JSP)

Active Server Pages Architecture

3. WWW and HTTP. Fig.3.1 Architecture of WWW

CS WEB TECHNOLOGY

Web Programming Paper Solution (Chapter wise)

CPET 581 E-Commerce & Business Technologies. Topics

Component Based Software Engineering

3. The pool should be added now. You can start Weblogic server and see if there s any error message.

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Planning and Designing Your Site p. 109 Design Concepts p. 116 Summary p. 118 Defining Your Site p. 119 The Files Panel p. 119 Accessing Your Remote

WWW Architecture I. Software Architecture VO/KU ( / ) Roman Kern. KTI, TU Graz

( A ) 8. If the address of an array is stored in $value, how do you get the values of this array? (B) \$value (C) &$value (D) $$value

Module 3 Web Component

Servlets by Example. Joe Howse 7 June 2011

Application Design and Development: October 30

CMPE 151: Network Administration. Servers

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes

Database Application Programs PL/SQL, Java and the Web

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Cloud Computing Platform as a Service

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 14 Database Connectivity and Web Technologies

Unit 4. CRM - Web Marketing 4-1

CE212 Web Application Programming Part 3

Developing a Mobile Web-based Application with Oracle9i Lite Web-to-Go

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

Jeff Offutt. SWE 432 Design and Implementation of Software for the Web. Web Applications

Programming the World Wide Web by Robert W. Sebesta

5/11/2009. Better to light a candle than to curse the darkness. Case Study: Reconnaissance Leaks & Corporate Assets

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

1Z Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions

Test On Line: reusing SAS code in WEB applications Author: Carlo Ramella TXT e-solutions

Programming the Web 06CS73 INTRODUCTION AND OVERVIEW. Dr. Kavi Mahesh, PESIT, Bangalore. Textbook: Programming the World Wide Web

4. กก ( Web-based Technology ) (System Development Life Cycle : SDLC) ก ก ก

COMP9321 Web Application Engineering

Servlet 5.1 JDBC 5.2 JDBC

Web Application Architectures

(p t y) lt d. 1995/04149/07. Course List 2018

EEC-682/782 Computer Networks I

********************************************************************

Using Java servlets to generate dynamic WAP content

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Chapter 10 Web-based Information Systems

Introduction. This course Software Architecture with Java will discuss the following topics:

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Backend. (Very) Simple server examples

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

Chapter 8 Web-based Information Systems

Web Architecture and Technologies

AJP. CHAPTER 5: SERVLET -20 marks

Design for Testability of Web Applications Manager s Perspective

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

COMP102: Introduction to Databases, 23

CSE 336. Introduction to Programming. for Electronic Commerce. Why You Need CSE336

Advanced Web Technology

Fall Semester (081) Module7: AJAX

COMP9321 Web Application Engineering

J2EE Web Development 13/1/ Application Servers. Application Servers. Agenda. In the beginning, there was darkness and cold.

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Session 10. Form Dataset. Lecture Objectives

Tutorial Point Servlets Pdf

Advanced Internet Technology Lab # 4 Servlets

HTML HTML. Chris Seddon CRS Enterprises Ltd 1

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

Notes General. IS 651: Distributed Systems 1

Web Programming. Lecture 11. University of Toronto

Lecture 9a: Sessions and Cookies

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

SAS Solutions for the Web: Static and Dynamic Alternatives Matthew Grover, S-Street Consulting, Inc.

when your Jaguar is caught in the Web

Developing Applications with Java EE 6 on WebLogic Server 12c

Three hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 21 st May Time:

Course Content. Outline of Lecture 10. Objectives of Lecture 10 DBMS & WWW. CMPUT 499: DBMS and WWW. Dr. Osmar R. Zaïane. University of Alberta 4

20. Web Hosting 웹프로그래밍 2016 년 1 학기 충남대학교컴퓨터공학과

Tutorial Point On Html5 Pdf

Distributed Multitiered Application

Hypertext Transport Protocol

Distributed Systems 1

Full Stack Web Developer

Edge Side Includes (ESI) Overview

Transcription:

Chapter 8: Application Design and Development ICOM 5016 Database Systems Web Application Amir H. Chinaei Department of Electrical and Computer Engineering University of Puerto Rico, Mayagüez User Interfaces and Tools Web Interfaces to Databases Web Fundamentals Servlets and JSP Building Large Web Applications Slides are adapted from: Database System Concepts See www.db-book.com for conditions on re-use 2 Database System Concepts 8.2 Database Users User Interfaces and Tools Application Developers Build DB-enable applications Use SQL to pose queries with this applications DB Administrator Manage the DBMS Create and update schemas Use SQL to complete these tasks Specialized user Sends ad-hoc queries to extract data and build reports Use SQL to complete these tasks Naïve users Interact with DB via client application program Do no use SQL (some might not even have a clue about SQL) Most database users do not use a query language like SQL. Forms Graphical user interfaces Report generators Data analysis tools (Such as OLAP; Chapter 18) Many interfaces are Web-based Back-end (Web server) uses such technologies as Java servlets Java Server Pages (JSP), abstraction of Java servlets Active Server Pages (ASP) 3 4 8.3 8.4 1

Fat-Clients for Naïve Users Thin-Clients for Naïve Users Application Program DBMS Web Browser Web and Application Server DB DBMS DB 5 6 8.5 8.6 Trade-offs for Fat clients Trade-offs for Thin Clients Pros GUI friendly to users Powerful features for complex tasks Good use of workstation power Cons Lots of libraries and dependencies Need to install on every machine (hard to scale) Complex to track versions User usually break configuration files Current status Less common Pros Runs from Web browser Make application available everywhere Very scalable Application code is on application server managed by IT Maintenance free on the client side Easy to manage versions (code in on a single site) Well-understood User interface Cons GUI is usually weaker compared with Fat-clients JavaScript, JavaServer Faces and AJAX are changing this Session management can be an issue 7 8 8.7 8.8 2

The World Wide Web Web Interfaces to Databases The Web is a distributed information system based on hypertext. Most Web documents are hypertext documents formatted via the HyperText Markup Language (HTML) HTML documents contain text along with font specifications, and other formatting instructions hypertext links to other documents, which can be associated with regions of the text. forms, enabling users to enter data which can then be sent back to the Web server Why interface databases to the Web? 1. Web browsers have become the de-facto standard user interface to databases Enable large numbers of users to access databases from anywhere Avoid the need for downloading/installing specialized code, while providing a good graphical user interface Examples: banks, airline and rental car reservations, university course registration and grading, an so on. 9 10 8.9 8.10 Web Interfaces to Database (Cont.) 2. Dynamic generation of documents Limitations of static HTML documents Cannot customize fixed Web documents for individual users. Problematic to update Web documents, especially if multiple Web documents replicate data. Solution: Generate Web documents dynamically from data stored in a database. Can tailor the display based on user information stored in the database. E.g. tailored ads, tailored weather and local news, Displayed information is up-to-date, unlike the static Web pages E.g. stock market information,.. Early Web-based frameworks Common Gateway Interface (CGI) Plug-ins for Web browser Written in C, C++ or Perl Hard to maintain and scale due to difficulty Supporting multi-threading Packaging as components PHP Better components Hard to debug and maintain code JSP, ASP Easier to maintain Access to modern development tools Good performance 11 12 8.11 8.12 3

Three-Tier Web Architecture Two-Tier Web Architecture Multiple levels of indirection have overheads Alternative: two-tier architecture 13 14 8.13 8.14 Model 1 Web Architecture Model 2 Web Architecture (MVC) DB Access Components Access Control Components (Control) DB Access Components (Model) Application Server Application Server Web Page Web Page GUI Components GUI Components (View) In Model 1 View and Logic are mixed in the Web page (e.g. JSP) DBMS DB In Model 2 View, control Logic are separated (e.g. JSP, JSF) DBMS DB 15 16 8.15 8.16 4

A formatted report Uniform Resources Locators In the Web, functionality of pointers is provided by Uniform Resource Locators (URLs). URL example: http://www.bell-labs.com/topics/book/db-book The first part indicates how the document is to be accessed http indicates that the document is to be accessed using the Hyper Text Transfer Protocol. The second part gives the unique name of a machine on the Internet. The rest of the URL identifies the document within the machine. The local identification can be: The path name of a file on the machine, or An identifier (path name) of a program, plus arguments to be passed to the program E.g. http://www.google.com/search?q=silberschatz 17 18 8.17 8.18 HTML and HTTP HTML provides formatting, hypertext link, and image display features. HTML also provides input features Select from a set of options Pop-up menus, radio buttons, check lists Enter values Text boxes Filled in input sent back to the server, to be acted upon by an executable at the server HyperText Transfer Protocol (HTTP) used for communication with the Web server Sample HTML Source Text <html> <body> <table border cols = 3> <tr> <td> A-101 </td> <td> Downtown </td> <td> 500 </td> </tr> </table> <center> The <i>account</i> relation </center> <form action= BankQuery method=get> Select account/loan and enter number <br> <select name= type > <option value= account selected> Account <option value= Loan > Loan </select> <input type=text size=5 name= number > <input type=submit value= submit > </form> </body> </html> 19 20 8.19 8.20 5

Display of Sample HTML Source Client Side Scripting and Applets Browsers can fetch certain scripts (client-side scripts) or programs along with documents, and execute them in safe mode at the client site Javascript Macromedia Flash and Shockwave for animation/games VRML Applets Client-side scripts/programs allow documents to be active E.g., animation by executing programs at the local site E.g. ensure that values entered by users satisfy some correctness checks Permit flexible interaction with the user. Executing programs at the client site speeds up interaction by avoiding many round trips to server 21 22 8.21 8.22 Client Side Scripting and Security Security mechanisms needed to ensure that malicious scripts do not cause damage to the client machine Easy for limited capability scripting languages, harder for general purpose programming languages like Java E.g. Java s security system ensures that the Java applet code does not make any system calls directly Disallows dangerous actions such as file writes Notifies the user about potentially dangerous actions, and allows the option to abort the program or to continue execution. Web Servers A Web server can easily serve as a front end to a variety of information services. The document name in a URL may identify an executable program, that, when run, generates a HTML document. When a HTTP server receives a request for such a document, it executes the program, and sends back the HTML document that is generated. The Web client can pass extra arguments with the name of the document. To install a new service on the Web, one simply needs to create and install an executable that provides that service. The Web browser provides a graphical user interface to the information service. Common Gateway Interface (CGI): a standard interface between web and application server 23 24 8.23 8.24 6

HTTP and Sessions Sessions and Cookies The HTTP protocol is connectionless That is, once the server replies to a request, the server closes the connection with the client, and forgets all about the request In contrast, Unix logins, and JDBC/ODBC connections stay connected until the client disconnects retaining user authentication and other information Motivation: reduces load on server operating systems have tight limits on number of open connections on a machine Information services need session information E.g. user authentication should be done only once per session Solution: use a cookie A cookie is a small piece of text containing identifying information Sent by server to browser on first interaction Sent by browser to the server that created the cookie on further interactions part of the HTTP protocol Server saves information about cookies it issued, and can use it when serving a request E.g., authentication information, and user preferences Cookies can be stored permanently or for a limited time 25 26 8.25 8.26 JDBC/DB Connection String username="amir" ; String password="chinaei"; String dbdriver="com.mysql.jdbc.driver"; String dbaddress="jdbc:mysql://localhost:port#/g09"; Class.forName(dbDriver); Connection conn; conn = DriverManager.getConnection(dbAddress,userName,pa ssword); Statement stmt; stmt=conn.createstatement(); ResultSet rset=null; String q1= Select. ; OR String q2= Insert. ; rset= stmt.executequery(q1); OR rset= stmt.executeupdate(q2); JDBC/Excecute Use try/catch to capture SQL exceptions. stmt.close(); conn.close(); 27 28 8.27 8.28 7

Servlets Java Servlet specification defines an API for communication between the Web server and application program E.g. methods to get parameter values and to send HTML text back to client Application program (also called a servlet) is loaded into the Web server Two-tier model Each request spawns a new thread in the Web server thread is closed once the request is serviced Servlet API provides a getsession() method Sets a cookie on first interaction with browser, and uses it to identify session on further interactions Provides methods to store and look-up per-session information E.g. user name, preferences,.. Example Servlet Code Public class BankQueryServlet extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse result) throws ServletException, IOException { } } String type = request.getparameter( type ); String number = request.getparameter( number ); code to find the loan amount/account balance using JDBC to communicate with the database.. we assume the value is stored in the variable balance result.setcontenttype( text/html ); PrintWriter out = result.getwriter( ); out.println( <HEAD><TITLE>Query Result</TITLE></HEAD> ); out.println( <BODY> ); out.println( Balance on + type + number + = + balance); out.println( </BODY> ); out.close ( ); 29 30 8.29 8.30 Server-Side Scripting Improving Web Server Performance Server-side scripting simplifies the task of connecting a database to the Web Define a HTML document with embedded executable code/sql queries. Input values from HTML forms can be used directly in the embedded code/sql queries. When the document is requested, the Web server executes the embedded code/sql queries to generate the actual HTML document. Numerous server-side scripting languages JSP, Server-side Javascript, ColdFusion Markup Language (cfml), PHP, Jscript General purpose scripting languages: VBScript, Perl, Python Performance is an issue for popular Web sites May be accessed by millions of users every day, thousands of requests per second at peak time Caching techniques used to reduce cost of serving pages by exploiting commonalities between requests At the server site: Caching of JDBC connections between servlet requests Caching results of database queries Cached results must be updated if underlying database changes Caching of generated HTML At the client s network Caching of pages by Web proxy 31 Recommended exercises: 8.1, 8.2, 8.3, 8.8, 8.9 32 8.31 8.32 8