Distributed Systems 1

Similar documents
Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

The World Wide Web. Internet

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

Session 8. Introduction to Servlets. Semester Project

RESTful Services. Distributed Enabling Platform

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

1.1 A Brief Intro to the Internet

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

Web Development and HTML. Shan-Hung Wu CS, NTHU

Web Programming. Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun.

Session 9. Introduction to Servlets. Lecture Objectives

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

1.1 A Brief Intro to the Internet

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

Module 3 Web Component

CSSE 460 Computer Networks Group Projects: Implement a Simple HTTP Web Proxy

Developing Applications with Java EE 6 on WebLogic Server 12c

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

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

Advanced Internet Technology Lab # 4 Servlets

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Unit 4 The Web. Computer Concepts Unit Contents. 4 Web Overview. 4 Section A: Web Basics. 4 Evolution

C22: Browser & Web Server Communication

Servlet Fudamentals. Celsina Bignoli

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

Application Protocols and HTTP

Lecture 9a: Sessions and Cookies

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers

Application Layer: The Web and HTTP Sec 2.2 Prof Lina Battestilli Fall 2017

Unraveling the Mysteries of J2EE Web Application Communications

Advanced Web Technology

1.1 A Brief Intro to the Internet

Announcements Fawzi Emad, Computer Science Department, UMCP

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Chapter 10 Servlets and Java Server Pages

CS 43: Computer Networks. Layering & HTTP September 7, 2018

Lecture 7b: HTTP. Feb. 24, Internet and Intranet Protocols and Applications

World-Wide Web Protocols CS 571 Fall Kenneth L. Calvert All rights reserved

Servlet and JSP: A Beginner's Tutorial First Edition

Web based Applications, Tomcat and Servlets - Lab 3 -

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Web Information System Design. Tatsuya Hagino

UR what? ! URI: Uniform Resource Identifier. " Uniquely identifies a data entity " Obeys a specific syntax " schemename:specificstuff

HTTP Reading: Section and COS 461: Computer Networks Spring 2013

HTTP Security. CSC 482/582: Computer Security Slide #1

Applications & Application-Layer Protocols: The Web & HTTP

The HTTP protocol. Fulvio Corno, Dario Bonino. 08/10/09 http 1

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Servlet Basics. Agenda

Apache Wink Developer Guide. Draft Version. (This document is still under construction)

ICS 351: Today's plan. IPv6 routing protocols (summary) HTML HTTP web scripting languages certificates (review) cookies

Network Working Group Request for Comments: 2318 Category: Informational W3C March 1998

Web Programming Paper Solution (Chapter wise)

Web Site Design and Development. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

The HTTP Protocol HTTP

Introduction to web development and HTML MGMT 230 LAB

Stateless -Session Bean

MASTERS COURSE IN FULL STACK WEB APPLICATION DEVELOPMENT W W W. W E B S T A C K A C A D E M Y. C O M

Table of Contents WWW. WWW history (2) WWW history (1) WWW history. Basic concepts. World Wide Web Aka The Internet. Client side.

Computer Networks. Wenzhong Li. Nanjing University

Traditional Web Based Systems

Head First Servlets And JSP: Passing The Sun Certified Web Component Developer Exam (SCWCD) By Kathy Sierra, Bryan Basham

Announcements Fawzi Emad, Computer Science Department, UMCP

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

Project 2 Implementing a Simple HTTP Web Proxy

Web Standards. Web Technologies. Web Standards. URI and URL

CS637 Midterm Review

How to Install (then Test) the NetBeans Bundle

COSC 2206 Internet Tools. The HTTP Protocol

Internet Content Distribution

What is a web site? Web editors Introduction to HTML (Hyper Text Markup Language)

Web, HTTP and Web Caching

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

Project 2 Group Project Implementing a Simple HTTP Web Proxy

Networking and Internet

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

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

Distributed Systems Project 1 Assigned: Friday, January 26, 2018 Due: Friday, February 9, 11:59 PM

LAMP, WEB ARCHITECTURE, AND HTTP

REST Easy with Infrared360

How to work with HTTP requests and responses

Tutorial 1: HTML Tutorial (Windows Version) HTML (Hypertext Markup Language) Basics Objectives

CS631 - Advanced Programming in the UNIX Environment

2. Introduction to Internet Applications

AIM. 10 September

Java Servlets. Preparing your System

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

Programming the World Wide Web by Robert W. Sebesta

HTML: Introduction CISC 282. September 11, What is HTML?

powered by Series of Tubes Senator Ted Stevens talking about the Net Neutrality Bill Jul 17, powered by

Introduction to JSP and Servlets Training 5-days

Semantic Web Lecture Part 1. Prof. Do van Thanh

Zero Latency HTTP The comet Technique

Servlets and JSP (Java Server Pages)

Web Presentation Patterns (controller) SWEN-343 From Fowler, Patterns of Enterprise Application Architecture

Web Design E M I R R A H A M A N WEB DESIGN SIDES 2017 EMIR RAHAMAN 1

JAVA SERVLET. Server-side Programming INTRODUCTION

Transcription:

95-702 Distributed Systems 1

Joe Intro Syllabus highlights 95-702 Distributed Systems 2

Understand the HTTP application protocol Request and response messages Methods / safety / idempotence Understand Java server-side web application terminology Servlet jsp Web container HttpServlet Understand the flow of control Web server, web container, servlet Understand flow of request to response HttpServletRequest HttpServletResponse Understand MVC in servlets and jsp. 95-702 Distributed Systems 3

Sir Tim Berners Lee 2016 Turing Award winner Defined 3 standards: 1. Hypertext Transfer Protocol (HTTP) 2. Uniform Resource Identifiers (URI) UR Locators (URL) e.g. http://cmu.edu/heinz scheme://domain:port/path?query_string#fragment_id UR Names (URN) e.g. urn:isbn:0132143011 urn:namespace_identifier:namespace_specific_string 3. Hypertext Markup Language (HTML) Then implemented to these standards: A server program A browser program Source: Wikipedia 95-702 Distributed Systems 4

The Internet Engineering Task Force (IETF) of the Internet Society, in cooperation with the World Wide Web Consortium (W3C) ietf.org w3.org 95-702 Distributed Systems 5

If you have not used HTML before, you should learn the basics. W3Schools is a good HTML tutorial resource Do the HTML Tutorial from start through the "HTML Attributes" page (6 pages) http://www.w3schools.com/html Do all the "HTML Forms" pages (4 pages) http://www.w3schools.com/html/html_forms.asp Lynda is another good resource: http://www.cmu.edu/lynda/ 95-702 Distributed Systems 6

Cascading Style Sheets (CSS) provide web-page styling e.g. layout, fonts, colors We do not require any CSS in this class. But you can add some if you like to make your small apps look better. W3Schools CSS Tutorial: http://www.w3schools.com/css 95-702 Distributed Systems 7

Basic HTML pages are static, and sometimes you want to include dynamic content E.g. include values from a database query in a table. As you saw in the lab HelloWorld servlet example, you can write HTML directly in a servlet. e.g. out.println("<html>"); out.println("<head>"); Getting the HTML structure right can be troublesome. What would be nice, would be to have the HTML structure (as a template), but be able to replace pieces programmatically. JSP is a templating language Allows you to write HTML templates and fill in values using Java code Predecessor to newer templating engines E.g. erb (Ruby) and ejs (JavaScript) 95-702 Distributed Systems 8

Uses Request / Response interaction pattern Client Establishes a connection with the server Sends a request message and waits Server Processes the request as it is received Sends a response message over the same client connection Coupled in time: Both client and server must be available at time of the interaction Coupled in space: Both client and server must know the address of each other, and communicate directly point-to-point Can also be used for Request / Acknowledge 95-702 Distributed Systems 10

Source: Head First Servlets and JSP by Basham, Sierra, & Bates 95-702 Distributed Systems 11

General Format <method> <resource identifier> <HTTP Version> <crlf> [<Header>: <value>] <crlf>... [<Header>: <value>] <crlf> a blank line [entity body] Example GET /course/95-702/ HTTP/1.1 Host: www.andrew.cmu.edu User-Agent: Joe typing Accept: text/html This line intentionally left blank Method GET, PUT, DELETE, HEAD, POST, etc. Resource identifier specifies the name of the target resource; i.e. it's the URL stripped of the protocol and the server domain name. When using the GET method, this field will also contain a series of name=value pairs separated by &. When using a POST method, the entity body contains these pairs. HTTP version identifies the protocol used by the client. 95-702 Distributed Systems 12

General Format <HTTP Version> <Status> <crlf> [<Header>: <value>] <crlf>... [<Header>: <value>] <crlf> a blank line [response body] Example HTTP/1.1 200 OK Date: Mon, 13 Jan 2014 15:43:08 GMT Server: Apache/1.3.39 (Unix) mod_throttle/3.1.2... Set-Cookie: webstats-cmu=cmu128.2.87.50.8400;... Last-Modified: Sun, 12 Jan 2014 21:46:30 GMT Accept-Ranges: bytes Content-Length: 9014 Content-Type: text/html This line intentionally left blank <HTML> <HEAD> <META http-equiv="content-type" content="text/html; charset=utf-8">... HTTP version identifies the protocol used by the client. Status indicates the result of the request 95-702 Distributed Systems 13

200 OK 301 Moved Permanently 400 Bad Request 401 Unauthorized 404 Not found 500 Internal Server Error You get this when your server program throws an uncaught exception. You are likely to see this frequently this semester! For more information, see the standard: http://www.w3.org/protocols/rfc2616/rfc2616-sec10.html 95-702 Distributed Systems 14

Show with curl Show in Chrome Intro: https://developers.google.com/web/tools/chrome-devtools Show Network tab Inspect a particular request Request and Response Headers Response data Mertz - Mobile to Cloud 15

Most frequently used: GET retrieve information HEAD query if there is information to retrieve POST add or modify a resource's information if the resource identity is not known PUT add or replace a resource's information if the resource identity is known (add) or can be predicted (replace) DELETE delete information When choosing which HTTP methods to implement, consider: Safety Idempotence 95-702 Distributed Systems 16

You should study and know: What safe means What idempotent means Why idempotent is useful (hint: it has to do with failure) The common HTTP methods (previous slide) What they are used for Whether they defined as being safe Whether they defined as being idempotent Good resource to study: https://tools.ietf.org/html/rfc7231#section-4 95-702 Distributed Systems 17

Interesting test question: Should HTTP DELETE be safe? Should HTTP DELETE be idempotent? How would you handle receiving an HTTP DELETE referring to a resource that has already been deleted? 95-702 Distributed Systems 18

Method Purpose? Safe? Idempotent? GET Retrieve a resource Y Y PUT Insert or replace a resource N Y DELETE Remove a resource N Y HEAD Get header information only of a resource Y Y POST Add or modify a resource N N 95-702 Distributed Systems 19

HTTP is a standard. How it is actually implemented depends on the developer. A developer could choose to use HTTP DELETE to add records to a database. Good question to ponder: What benefit is there to following standards? Misuse is common E.g. Flickr uses GET to do everything, including removing a photo from your favorites list http://api.flickr.com/services/rest/?method=flickr.favo rites.remove& 95-702 Distributed Systems 20

A new version of HTTP is being adopted. Read this good HTTP/2 FAQ https://http2.github.io/faq/#general-questions Know for the exam, at a high level, what are the key differences from HTTP/1.x? (There is a bullet list in the FAQ.) 95-702 Distributed Systems 21

What does a server do when it receives an HTTP request? Java Enterprise Edition (JEE) is the platform (i.e. set of classes) for building distributed systems in Java. HttpServlet (commonly called a "Servlet") is the class designed to process HTTP requests. Great Reference: Head First Servlets & JSP by Bryan Basham; Kathy Sierra; Bert Bates Ch 1 3 95-702 Distributed Systems 22

In init() you might: Initialize a database Open file(s) Register with other objects Connect (sockets) to other services Source: Head First Servlets and JSP by Basham, Sierra, & Bates 95-702 Distributed Systems 23

You must overwrite one of: doget dopost doput dodelete dohead Source: Head First Servlets and JSP by Basham, Sierra, & Bates 95-702 Distributed Systems 24

In destroy() you might: Close a database or file Clean up relationships to other objects Close (sockets) Source: Head First Servlets and JSP by Basham, Sierra, & Bates 95-702 Distributed Systems 25

You implement, e.g., doget(httpservletrequest request, HttpServletResponse response) Source: Head First Servlets and JSP by Basham, Sierra, & Bates 95-702 Distributed Systems 26

MVC is discussed in the Lab 2 Video 3 Controller 1 or more servlets Extend HttpServlet Parse request Determine route Call model(s) Dispatches view Model(s) 1 or more POJOs Business logic Manages data Communicates with DB Communicates with other services Web Container Fetches data from model Gets attributes from controller Formats response View(s) 1 or more.jsp files 95-702 Distributed Systems 27

See handout, only available in class. 95-702 Distributed Systems 28

Please take the short survey at: http://tinyurl.com/95702prior Don't do now, I will send the link to you after class 95-702 Distributed Systems 29