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

Slides:



Advertisements
Similar presentations
Servlets. Servlets are modules that extend Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry.
Advertisements

HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
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.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
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 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.
How the web works: HTTP and CGI explained
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.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Client, Server, HTTP, IP Address, Domain Name. Client-Server Model Client Bob Yahoo Server yahoo.com/finance.html A text file named finance.html.
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 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.
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.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
HTTP – HyperText Transfer Protocol
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
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.
CS 190 Lecture Notes: Tweeter ProjectSlide 1 Uniform Resource Locators (URLs) Scheme Host.
Web application architecture
Sistem Jaringan dan Komunikasi Data #9. DNS The Internet Directory Service  the Domain Name Service (DNS) provides mapping between host name & IP address.
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.
Proxy Lab Recitation I Monday Nov 20, 2006.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms A form is the usual way to communicate information from a Web browser to a server HTML has.
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.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms - A form is the usual way information is gotten from a browser to a server - HTML has tags.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
Chapter 19 Creating and Processing HTML Forms. How HTML Forms Transmit Data name1=value1&name2=value2...&nameN =valueN GET or POST GET, an HTTP GET request,
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.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
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.
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.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Web Caching. Why Caching? Faster browsing experience for users Cache hit rate Traffic Prioritization Reduce network bandwidth requirements significantly.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
Servlets.
CS320 Web and Internet Programming Generating HTTP Responses
CS3220 Web and Internet Programming HTML Tables and Forms
WEB API.
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 Handling HTTP Requests
CS3220 Web and Internet Programming Cookies and Session Tracking
HTTP Hypertext Transfer Protocol
Presentation transcript:

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

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

HttpServletRequest getXxx() methods 5/docs/servlet-2_5- mr2/javax/servlet/http/HttpServletRequ est.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

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 some text

Example: Guestbook Filter HTML characters <: < >: > “: " &: &

HTTP Request as User Input HTTP Request Request line and header fields Query string Form data Important classes HttpServletRequest and its superclass ServletRequest It’s still Java!