1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.

Slides:



Advertisements
Similar presentations
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
Advertisements

M-V-C for web applications. Model for Web Applications model consists of data and system state database tables –persistent data session information –current.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
DT228/3 Web Development WWW and Client server model.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
Introduction to Web Interface Technology (CSE2030)
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.
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Introduction to Servlet & JSP
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Definition Servlet: Servlet is a java class which extends the functionality of web server by dynamically generating web pages. Web server: It is a server.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
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.
Apache Jakarta Tomcat Suh, Junho. Road Map Tomcat Overview Tomcat Overview History History What is Tomcat? What is Tomcat? Servlet Container.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Server-side Technologies
Introduction Servlets and JSP Celsina Bignoli
Applets & Servlets.
Week 7 Lecture Web Database Development Samuel Conn, Asst. Professor
Java Servelets. What Is a Servlet? A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed.
Introduction to Internet Programming (Web Based Application)
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
CSC 2720 Building Web Applications
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Copyright, 1996 © Dale Carnegie & Associates, Inc. Presented by Hsiuling Hsieh Christine Liu.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
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)
MC365 Application Servers, Servlets, and Java Server Pages (JSP’s): Tomcat.
Java Servlet API CGI / HTTP Concepts Java Servlet API.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
Java Servlets and Java Server Pages Norman White Stern School of Business.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
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.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 14 Database Connectivity and Web Technologies.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Java Servlets and Java Server Pages
How CGI and Java Servlets are Run By David Stein 14 November 2006.
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.
Lect5.ppt - 02/23/06 CIS 4100 Systems Performance and Evaluation Lecture 6 by Zornitza Genova Prodanoff.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Distributed Web Systems Java Servlets Lecturer Department University.
CS122B: Projects in Databases and Web Applications Spring 2017
CS122B: Projects in Databases and Web Applications Winter 2017
Introduction Servlets and JSP
Servlets.
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
PHP / MySQL Introduction
Chapter 26 Servlets.
CS122B: Projects in Databases and Web Applications Winter 2018
Introduction to Servlets
CS122B: Projects in Databases and Web Applications Spring 2018
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B

2 Outline Web applications: overview CGI and its variants Server Extension APIs Java servlets Comparisons

CS122B3 Web Applications Create dynamic content for a web page –keyword search on a document archive –E-commerce –…–… Example: –Amazon.com –Google.com

CS122B4 CGI CGI (Common Gateway Interface) –One of the first techniques for creating dynamic HTML pages Goal: –Define a standard method for a server to talk with external applications Example:

CS122B5 Main Process CGI-based Web Server e.g., apache Child Process for CGI1 Child Process for CGI1 Request for CGI 1 Request for CGI 1 Request for CGI 2 Child Process for CGI2 Child Process for CGI2 Child Process for CGI1 Child Process for CGI1 CGI life cycle

CS122B6 CGI Life Cycle (cont) Server receives a request for a CGI program Server creates a new process to run the CGI program Server passes information to the program: –via environment variables and standard input.

CS122B7 Processes are expensive Comparison between processes and threads cs194/05/notes/4-ProcThread.pdf

CS122B8 Problems with CGI Expensive to create a process for each request: –requires time and significant server resources, –limits the # of requests a server can handle concurrently Stateless: No history remembered –“Memento”  –A big problem for web-based development –Solutions: cookies –Still expensive

CS122B9 Problems with CGI (cont) Once the CGI program starts: –It cannot interact with the web server –It cannot take advantage of the server's abilities once it begins execution Reasons: the program is running in a separate process. Example, a CGI script cannot write to the server's log file.

CS122B10 Languages for CGI Scripts C/C++ Perl is becoming popular: – advanced text-processing capabilities – big help in managing details of CGI interface – platform independence –  requires each request start a separate Perl interpreter, which takes even more time and requires extra resources.

CS122B11 Ways to improve cgi performance FastCGI Other solutions

CS122B12 Main Process CGI-based Web Server Single Child Process for CGI1 Single Child Process for CGI1 Request for CGI 1 Request for CGI 1 Request for CGI 2 Child Process for CGI2 Child Process for CGI2 FastCGI

CS122B13 FastCGI (cont) Developed by a company “Open Market” FastCGI creates a single persistent process for each FastCGI program It eliminates the need to create a new process for each request. See:

CS122B14 FastCGI: /  No need to start multiple processes for different requests for the same fastcgi program  Still needs one process for each cgi program. –Thus not scalable to handle many concurrent requests  It does nothing to help the FastCGI program more closely interact with the server. –Not implemented by some of the more popular servers, I.e., Microsoft's Internet Information Server.  Not very portable For performance improvement, check: May/ html May/ html

CS122B15 Other solutions Proprietary solutions that work only with certain web servers. Platform dependent Examples: ASP (Microsoft), Server-side JavaScript (Netscape)

CS122B16 Server Extension APIs Proprietary server extension APIs for example: –Netscape provides an internal API called NSAPI –Microsoft provides ISAPI –Exist within the main process of a web server

CS122B17 Request for Server Extension 1 Main Process Web Server with Server Extension API Server Extension 1 Server Extension 2 Request for Server Extension 2 Request for Server Extension 1 Server Extension APIs life cycle

CS122B18 Server Extension APIs Write server extensions that enhance or change the base functionality of the server Allowing the server to handle tasks that were once relegated to external CGI programs. Use linked C or C++ code –Thus can run extremely fast; and –make full use of the server's resources.

CS122B19 Server Extension APIs:  Difficult to develop and maintain Pose significant security and reliability hazards –a crashed server extension can bring down the entire server. Proprietary server extensions are tied to the server API on a particular OS –Not very portable

CS122B20 Active Server Pages (ASP) Developed by Microsoft With ASP, an HTML page on the web server can contain snippets of embedded code: –usually VBScript or Jscript –it's possible to use nearly any language This code is read and executed by the web server before it sends the page to the client. ASP is optimized for generating small portions of dynamic content. Support for ASP is built into Microsoft Internet Information Server Version 3.0 and above

CS122B21 ASP example tinghttp:// ting The browser shows: Hello World!

CS122B22 Server-side JavaScript (SSJS) Developed by Netscape Allows snippets of code to be embedded in HTML pages to generate dynamic web content. Difference: SSJS uses JavaScript as the scripting language. Support for server-side JavaScript is available only with Netscape FastTrack Server and Enterprise Server Version 2.0 and above.

A Servlet is a Service Unit Java Servlet Based Web Server Main Process Web Server JVM Servlet1 Servlet2 Request for Servlet 1 Threa d Request for Servlet 1 Threa d Request for Servlet 2 Threa d CS122B23

Life With Servlets A servlet is a service unit which runs inside a web server, extending its functionality beyond the basic GET, POST, DELETE and PUT operations. CS122B24

Inside a Servlet A servlet does not have a main() method. – a Java program: yes – an applet: no Certain methods of a servlet are invoked by the server in the process of handling requests. Each time the server dispatches a request to a servlet, it invokes the servlet's service() method. CS122B25

Servlet Package Hierarchy JAVAX GenericServlet Servlet HttpServlet Form Servlet Admin Servlet CGI Servlet Error Servlet File Servlet Image Servlet CS122B26

The Servlet Interface Servlet interface { void init(ServletConfig sc) throws ServletException; void service(ServletRequest req, ServletResponse res); throws ServletException, IOException; void destroy(); } CS122B27

GenericServlet Class et/GenericServlet.html Server request response service( ) GenericServlet subclass Override the service() method CS122B28

HttpServlet Class et/http/HttpServlet.html java.lang.Object  javax.servlet.GenericServlet  javax.servlet.http.HttpServletjavax.servlet.GenericServlet A function: protected void doGet(HttpServletRequest req, HttpServletResponse resp)doGetHttpServletRequest HttpServletResponse CS122B29

Request and Response Objects They form the core objects for communication. HttpServletRequest contains all the details about the client request to the servlet. For e.g., request.getParameter(”paramName”); HttpServletResponse contains all the information for replying back to the client. For e.g., the output stream. CS122B30

CS122B31 Comparisons CGI/FastCGI: use multiple processes to handle separate programs and/or separate requests Outside the server Servlets: handled by separate threads within the web server process. Thus more efficient and scalable. can interact very closely with the server to do things that are not possible with CGI scripts.

CS122B32 Comparisons (cont) Java Servlets are portable: across operating systems (java) across web servers, since all major web servers support servlets. Thus, Java servlets offer a good platform for web-application development