CS320 Web and Internet Programming Generating HTTP Responses

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Advertisements

HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
HTTP – HyperText Transfer Protocol
Web basics HTTP – – URI/L/Ns – HTML –
1 HTTP and some other odds and ends Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
16-Jun-15 HTTP Hypertext Transfer Protocol. 2 HTTP messages HTTP is the language that web clients and web servers use to talk to each other HTTP is largely.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
Data and Computer Communications Eighth Edition by William Stallings Lecture slides by Lawrie Brown Chapter 23 – Internet Applications Internet Directory.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Know how HTTP accesses data on the WWW Objectives.
Hypertext Transfer Protocol Information Systems 337 Prof. Harry Plantinga.
CS 142 Lecture Notes: HTTPSlide 1 HTTP Request GET /index.html HTTP/1.1 Host: User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language:
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
Client, Server, HTTP, IP Address, Domain Name. Client-Server Model Client Bob Yahoo Server yahoo.com/finance.html A text file named finance.html.
CSC 2720 Building Web Applications Servlet – Getting and Setting HTTP Headers.
 What is it ? What is it ?  URI,URN,URL URI,URN,URL  HTTP – methods HTTP – methods  HTTP Request Packets HTTP Request Packets  HTTP Request Headers.
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Web Hacking 1. Overview Why web HTTP Protocol HTTP Attacks 2.
Introduction to Web Programming Fall 2014/2015 Some slides are based upon Web Technologies course slides, HUJI, 2009 Extended System Programming Laboratory.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
COMP3016 Web Technologies Introduction and Discussion What is the Web?
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
1 Lecture #7-8 HTTP – HyperText Transfer Protocol HAIT Summer 2005 Shimrit Tzur-David.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
2: Application Layer1 CS 4244: Internet Software Development Dr. Eli Tilevich.
Application Layer 2 Figures from Kurose and Ross
CS 190 Lecture Notes: Tweeter ProjectSlide 1 Uniform Resource Locators (URLs) Scheme Host.
Generating the Server Response: HTTP Response Headers.
Sistem Jaringan dan Komunikasi Data #9. DNS The Internet Directory Service  the Domain Name Service (DNS) provides mapping between host name & IP address.
WWW, HTTP, GET, POST, Cookies Svetlin Nakov Telerik Corporation
IT Engineering Instructor: Rezvan Shiravi
WebServer A Web server is a program that, using the client/server model and the World Wide Web's Hypertext Transfer Protocol (HTTP), serves the files that.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
The HyperText Transfer Protocol. History HTTP has been in use since 1990 (HTTP/0.9) HTTP/1.0 was defined in RFC 1945 (May 1996) and included metainformation.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
Slides © Marty Hall, book © Sun Microsystems Press 1 Generating the HTTP Response Core Servlets & JSP book:
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Web Server Design Week 8 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/3/10.
HyperText Transfer Protocol (HTTP) RICHI GUPTA CISC 856: TCP/IP and Upper Layer Protocols Fall 2007 Thanks to Dr. Amer, UDEL for some of the slides used.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10.
A Little Bit About Cookies Fort Collins, CO Copyright © XTR Systems, LLC A Little Bit About Cookies Instructor: Joseph DiVerdi, Ph.D., M.B.A.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
The Basics of HTTP Jason Dean
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.
HTTP Here, we examine the hypertext transfer protocol (http) – originally introduced around 1990 but not standardized until 1997 (version 1.0) – protocol.
SKT-SSU IT Training Center Servlet and JSP. Chapter Seven: Generating the Server Response: HTTP Response Headers.
® IBM Software Group © 2007 IBM Corporation Servlet API (Part II)
Servlets 4 Lec 30 Web Design and Development. Looking Back… Response Redirection  Sending a standard redirect  Sending a redirect to an error page Request.
Overview of Servlets and JSP
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
CS320 Web and Internet Programming Generating HTTP Responses
CS3220 Web and Internet Programming Generating HTTP Responses
Generating the Server Response: HTTP Status Codes
CS320 Web and Internet Programming Cookies and Session Tracking
CS3220 Web and Internet Programming Cookies and Session Tracking
CS3220 Web and Internet Programming Cookies and Session Tracking
Presentation transcript:

CS320 Web and Internet Programming Generating HTTP Responses Chengyu Sun California State University, Los Angeles

HTTP Response Example HTTP/1.1 200 OK Content-Type: text/html;charset=ISO-8859-1 Content-Length: 168 Date: Sun, 03 Oct 2004 18:26:57 GMT Server: Apache-Coyote/1.1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Servlet Life Cycle</title></head> <body> n is 299 and m is 440 </body> </html>

HTTP Response Status line Protocol Status code Header [Message body]

Common Status Codes 200 (OK) 401 (Unauthorized) 403 (Forbidden) 404 (Not Found) 500 (Internal Server Error)

Status Codes 100 – 199: Informational. Client should respond with further action 200 – 299: Request is successful 300 – 399: Files have moved 400 – 499: Error by the client 500 – 599: Error by the server

Redirect Codes 301 (Moved Permanently) 302 (Found) 303 (See Other) GET 302 (Found) a.k.a. (Moved Temporarily) 303 (See Other) GET and POST 307 (Temporary Redirect) GET but not POST

Header Fields Request Response Accept Accept-Charset Accept-Encoding Accept-Language Connection Content-Length Cookies Response Content-Type Content-Encoding Content-Language Connection Content-Length Set-Cookie

More Response Header Fields Location for redirect Refresh “Push” Incremental display Cache-Control, Expires, Pragma for cache policies

HttpServletResponse http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/http/HttpServletResponse.html

Header Methods in HttpServletResponse addHeader(), setHeader() addIntHeader(), setIntHeader() addDateHeader(), setDateHeader() containsHeader()

More HttpServletResponse Methods setContentType( String type ) sendRedirect( String location ) 302 Handle relative URL getWriter() For text responses, e.g. HTML pages getOutputStream For binary responses, e.g. images

Example: Add Revisited Redirect the user back to the input form if the parameters are missing or invalid sendRedirect()

Example: Countdown Automatically refreshes the display every second The Refresh header

Example: Download Download an image file from the server File I/O Content type Binary response The Content-Disposition header

HTTP Response as Program Output Understand the HTTP response format Remember the status code ranges and the common status codes Use of headers to generate “special” responses And it’s still Java!