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.

Slides:



Advertisements
Similar presentations
Enabling Secure Internet Access with ISA Server
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Chapter 61 Processing the Client Request JavaServer Pages By Xue Bai.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
The Client-Server Model for the Web 1. A Web Client (usually in the form of a web browser) makes an HTTP request to a specific web server. 2. The Web Server.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
CPSC 203 Introduction to Computers Tutorial 59 & 64 By Jie (Jeff) Gao.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Server-Side vs. Client-Side Scripting Languages
1 Chapter 12 Working With Access 2000 on the Internet.
XP Browser and Basics1. XP Browser and Basics2 Learn about Web browser software and Web pages The Web is a collection of files that reside.
Servlets and a little bit of Web Services Russell Beale.
Core Servlets chapter 5: HTTP request headers. Requesting header information It is possible that information the servlet needs is not in the form data.
How the web works: HTTP and CGI explained
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.
Internet – Part II. What is the World Wide Web? The World Wide Web is a collection of host machines, which deliver documents, graphics and multi-media.
1 Handling the Client Request: HTTP Request Headers Parts of this presentation was provided by Vijayan Sugumaran Department of DIS.
Introduction 2: Internet, Intranet, and Extranet J394 – Perancangan Situs Web Program Sudi Manajemen Universitas Bina Nusantara.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
UNIFORM RESOURCE LOCATOR (URL)
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.
 Proxy Servers are software that act as intermediaries between client and servers on the Internet.  They help users on private networks get information.
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.
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.
Boris Tshibangu. What is a proxy server? A proxy server is a server (a computer system or an application) that acts as an intermediary for requests from.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
1 Enabling Secure Internet Access with ISA Server.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Computer Concepts 2014 Chapter 7 The Web and .
J2EE training: 1 TODO Replace Netscape examples with Firefox. In later two sections also.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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.
Chapter 6 The World Wide Web. Web Pages Each page is an interactive multimedia publication It can include: text, graphics, music and videos Pages are.
Slides © Marty Hall, book © Sun Microsystems Press 1 Including Files & Applets in JSP Documents Core Servlets & JSP book:
What is an Internet Browser? Internet browser— An Internet browser is a client program that knows how to interpret HTML code and display information and.
HOW WEB SERVER WORKS? By- PUSHPENDU MONDAL RAJAT CHAUHAN RAHUL YADAV RANJIT MEENA RAHUL TYAGI.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
CS320 Web and Internet Programming Handling HTTP Requests Chengyu Sun California State University, Los Angeles.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
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.
1 After completing this lesson, you will be able to: Transfer your files to the Internet. Choose a method for posting your Web pages. Use Microsoft’s My.
SKT-SSU IT Training Center Servlet and JSP. Chapter Five: Handling the Client Request: HTTP Request Headers.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
1 Handling the Client Request: HTTP Request Headers.
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
Chapter 29 World Wide Web & Browsing World Wide Web (WWW) is a distributed hypermedia (hypertext & graphics) on-line repository of information that users.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
8-Mar-16 More About Servlets Session Tracking. Persistent information A server site typically needs to maintain two kinds of persistent (remembered) information:
11 SUPPORTING INTERNET EXPLORER IN WINDOWS XP Chapter 11.
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
Warm Handshake with Websites, Servers and Web Servers:
Some Common Terms The Internet is a network of computers spanning the globe. It is also called the World Wide Web. World Wide Web It is a collection of.
HTTP request message two types of HTTP messages: request, response
CS320 Web and Internet Programming Cookies and Session Tracking
Configuring Internet-related services
Web Privacy Chapter 6 – pp 125 – /12/9 Y K Choi.
Servlet APIs Every servlet must implement javax.servlet.Servlet interface Most servlets implement the interface by extending one of these classes javax.servlet.GenericServlet.
Web Page Concept and Design :
HyperText Transfer Protocol
Presentation transcript:

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 5.Implementing compression 6.Differentiating Among Different Browser Types 7.Changing the Page According to How the User Got There

1. Request headers Indirectly set by the browser And are sent immediately following the initial GET or POST request line. The request includes the headers Accept, Accept-Encoding, Connection, Cookie, Host, Referer, and User-Agent, all of which might be important to the operation of the servlet,

2. Reading Request Headers Call the getHeader method of HttpServletRequest with the name of the header. It returns a String if the specified header was supplied in the current request, null otherwise. In HTTP 1.0, all request headers are optional. In HTTP 1.1, only Host is required. So, always check for null before using a request header. Header names are not case sensitive

3. Making a Table of All Request Headers 3.1. Shows Request Headers 3.2. Solution 3.3. Making a table of All Request Headers

3.1. Shows Request Headers Request headers sent by Netscape on Windows 2000

3.1. Shows Request Headers Request headers sent by Netscape on Windows 2000

3.2. Solution

3.3. Making a Table of All Request Headers Listing 5.1 shows a servlet that simply creates a table of all the headers it receives, along with their associated values. calling request.getHeaderNames to obtain an Enumeration of headers in the current request. Enumeration is a standard interface in Java; it is in the java.util package and contains just two methods: hasMoreElements and nextElement.

4. Sending Compressed Web Pages Gzip is a text compression scheme that can dramatically reduce the size of HTML (or plain text) pages. Most recent browsers know how to handle gzipped content, so the server can compress the document and send the smaller document over the network

4. Sending Compressed Web Pages After which the browser will automatically reverse the compression (no user action required) and treat the result in the normal manner. If you send gzipped content to browsers that don't support this capability, the browsers will not be able to display the page at all

4. Sending Compressed Web Pages Browsers that support this feature indicate that they do so by setting the Accept- Encoding request header. Listing 5.2 shows a servlet that checks the Accept-Encoding header, sending a compressed Web page to clients that support gzip encoding (as determined by the isGzipSupported method of Listing 5.3) and sending a regular Web page to those that don'tListing 5.3

4. Sending Compressed Web Pages

Since the Windows version of Internet Explorer 6 supports gzip, this page was sent gzipped over the network and automatically reconstituted by the browser, resulting in a large saving in download time.

5. Implementing compression The gzip format is built in to the Java programming language by classes in java.util.zip. The servlet first checks the Accept- Encoding header to see if it contains an entry for gzip.

5. Implementing compression If so, it uses a PrintWriter wrapped around a GZIPOutputStream and specifies gzip as the value of the Content-Encoding response header. If gzip is not supported, the servlet uses the normal PrintWriter and omits the Content-Encoding header

5. Implementing compression To make it easy to compare regular and compressed performance with the same browser, we also added a feature whereby we can suppress compression by including ?disableGzip at the end of the URL.

6. Differentiating Among Different Browser Types 6.1. Sends browser-specific insults to users 6.2. Servlet: BrowserInsult.java 6.3. Differentiating Among Different Browser Types

6.1. Sends browser-specific insults to users

6.2. Servlet: BrowserInsult.java

6.3. Differentiating Among Different Browser Types The User-Agent header identifies the specific browser that is making the request Use User-Agent only when necessary. Check for null. All major browser versions send the User-Agent header. T he header is not required by the HTTP 1.1 specification, some browsers let you disable it (e.g., Opera), and custom clients (e.g., Web spiders or link verifiers) Always check that the result of request.getHeader is non-null before trying to use it

6.3. Differentiating Among Different Browser Types To differentiate between Netscape and Internet Explorer, check for "MSIE," not "Mozilla." Both Netscape and Internet Explorer say "Mozilla" at the beginning of the header. Listing 5.4 shows a servlet that sends browser-specific insults to users

7. Changing the Page According to How the User Got There 7.1. Customize Image Problem 7.2. Solution 7.3. Changing the Page According to How the User Got There

7.1. Customize Image Problem Uses the Referer header to customize the image it displays: If the address of the referring page contains the string "JRun," the servlet displays the logo of Macromedia JRun.

If the address contains the string "Resin," the servlet displays the logo of Caucho Resin.

Otherwise (the address of the referring page contains neither "JRun" nor "Resin."), the servlet displays the logo of Apache Tomcat. The servlet also displays the address of the referring page.

When the Referer header is missing

7.2. Solution: CustomizeImage.java Create a servlet that uses the Referer header to customize the image it displays

7.2. Solution: CustomizeImage.java

7.2. Solution: JRun-Referer.html We created three identical pages named JRun-Referer.html, Resin- Referer.html, and Tomcat-Referer.html; The servlet uses the name of the referring page, not form data, to distinguish among the three

7. Changing the Page According to How the User Got There The Referer header designates the location of the page users were on when they clicked a link to get to the current page. If users simply type the address of a page, the browser sends no Referer at all and request.getHeader("Referer") returns null.

7.3 Changing the Page According to How the User Got There This header enables you to customize the page depending on how the user reached it. For example Create a jobs/careers site that takes on the look and feel of the associated site that links to it. Change the content of a page depending on whether the link came from inside or outside the firewall. Supply links that take users back to the page they came from