CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

Chapter 61 Processing the Client Request JavaServer Pages By Xue Bai.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
Servlets and a little bit of Web Services Russell Beale.
1 HTTP – HyperText Transfer Protocol Part 1. 2 Common Protocols In order for two remote machines to “ understand ” each other they should –‘‘ speak the.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
CS320 Web and Internet Programming Generating HTTP Responses
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
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.
1 Static Web Pages Websites on Servers (The Big Picture) –Apache Tomcat can support static web pages –Primarily intended to support servlets and JSP –Some.
1 Web Search Interfaces. 2 Web Search Interface Web search engines of course need a web-based interface. Search page must accept a query string and submit.
Client, Server, HTTP, IP Address, Domain Name. Client-Server Model Client Bob Yahoo Server yahoo.com/finance.html A text file named finance.html.
 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.
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.
Rensselaer Polytechnic Institute CSC-432 – Operating Systems David Goldschmidt, Ph.D.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
HTTP HyperText Transfer Protocol Stateless request/response client-server protocol Requests: Method: GET, POST, HEAD, TRACE, OPTIONS, PUT, DELETE.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
HTTP – HyperText Transfer Protocol
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.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
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
Chapter 5 HTTP Request Headers. Content 1.Request headers 2.Reading Request Headers 3.Making a Table of All Request Headers 4.Sending Compressed Web Pages.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Website Development with PHP and MySQL Saving Data.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITCS373: Internet Technology Lecture 5: More HTML.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
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.
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.
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.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
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,
LURP Details. LURP Lab Details  1.Given a GET … call a proxy CGI script in the same way you would for a normal CGI request  2.This UDP perl.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
CS3220 Web and Internet Programming Introduction to Java Servlets
CS520 Web Programming Servlet and JSP Review
Servlets.
CS320 Web and Internet Programming Generating HTTP Responses
CS3220 Web and Internet Programming HTML Tables and Forms
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
CS3220 Web and Internet Programming Generating HTTP Responses
Introduction Web Environments
Chapter 26 Servlets.
CS320 Web and Internet Programming Cookies and Session Tracking
Servlet APIs Every servlet must implement javax.servlet.Servlet interface Most servlets implement the interface by extending one of these classes javax.servlet.GenericServlet.
CS3220 Web and Internet Programming Cookies and Session Tracking
CS3220 Web and Internet Programming HTML Tables and Forms
CS3220 Web and Internet Programming Introduction to Java Servlets
CS3220 Web and Internet Programming Handling HTTP Requests
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming Cookies and Session Tracking
HTTP Hypertext Transfer Protocol
PHP-II.
Presentation transcript:

CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles

HTTP Request As Input Browser Application Server HTTP request HTTP response program inputoutput

Examine HTTP Requests and Responses TCP/IP Monitor in Eclipse Browser plugins like HttpFox and Firebug

TCP/IP Monitor in Eclipse... Client localhost Server host:port request response TCP/IP Monitor ClientServer request response request response host:portlocalhost

... TCP/IP Monitor in Eclipse Window  Preferences  Run/Debug  TCP/IP Monitor Example: monitor the access of Local Monitoring Port?? Host?? Port?? Browser URL??

HTTP Request Example GET /foo HTTP/1.1 Host: cs.calstatela.edu:4040 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3)... Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,... Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO ,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: nxt/gateway.dll/uid=4B4CF072; SITESERVER=ID=f

HTTP Request Request line Method Request URI Protocol Header [Message body]

Request Methods Browser GET POST Editor PUT DELETE Diagnosis HEAD OPTIONS TRACE Actions to be performed regarding the resource identified by the Request URI

HttpServlet Methods GET  POST  PUT  DELETE  HEAD  OPTIONS  TRACE  doGet() doPost() doPut() doDelete() doHead() doOptions() doTrace() service()

Override HttpServlet Methods Default implementation returns an HTTP Bad Request error doGet(), doPost() Simply call one method from the other

Request Header Fields User-Agent Accept Accept-Charset Accept-Encoding Accept-Language Host Connection/Keep- alive Content-Length Cookie Referer RFC2616, Section 14

HttpServletRequest getXxx() methods pi/javax/servlet/http/HttpServletReques t.html

Example: RequestInfo Display some request information Method, request URI, request URL... Display the IP address of the client Determine if gzip compression supported

Request Parameters Query string ?param1=value1&param2=value2&... Form data

Example: Add Get two integers from request parameter and display the sum

Parameter Methods Inherited from ServletRequest String getParameter( String p ) Enumeration getParameterNames() String[] getParameterValues( String p ) Map getParameterMap()

HTML Forms action – URL of the server-side program that process the submitted form data method – GET or POST enctype  multipart/form-data for file uploading require POST

Understand URL Absolute URL Relative URL Relative to server root Relative to application root Relative to current URL

name value type Text field ?? Password field ?? Submit button ?? Reset button ?? Check box ?? Radio button ?? more types File upload Hidden field

name rows cols

name size multiple

Example: Guest Book John says:Hello! Jane says:Your website looks nice. Joe says:Nice to meet you. I’m from China. My Guest Book Add Comment Your name: Add Edit | Delete Edit Entry Your name: Save Jane Your website looks nice.

Web Application Web application = Data + Operations Data Guestbook entries, forum posts, products, customers, transactions, wiki pages, twitter message … Operations Add/create, search, display, edit, delete …

Guest Book Implementation Data GuestBookEntry List Operations Display Add Edit Delete

GuestBook – Display Initialize data storage in application scope Pre-create some data Generate HTML

GuestBook – Add Handling web forms usually involves two operations Display the form  doGet() Process the submission  doPost() response.sendRedirect()

GuestBook – Edit Embed an identifier of the data to be edited in generated hyperlink or form (using hidden form field)

GuestBook – Delete Use a unique and immutable identifier instead of array index

Summary HTTP Request Request line and header fields Query string Form data Important classes HttpServletRequest and its superclass ServletRequest Web application = Data + Operations