04-Request-Headers

04-Request-Headers - 2010 Marty Hall Handling the Client...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
© 2010 Marty Hall Handling the Client Request: HTTP Request Headers Originals of Slides and Source Code for Examples: http://courses coreservlets com/Cours Materials/csajsp2 htm Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. 2 http://courses.coreservlets.com/Course-Materials/csajsp2.html © 2010 Marty Hall For live Java EE training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF 1. x , JSF 2.0, Ajax (with jQuery, Dojo, Prototype, Ext-JS, Google Closure, etc.), GWT 2.0 (with GXT), Java 5, Java 6, SOAP-based and RESTful Web Services, Spring, Hibernate/JPA, and customized combinations of topics. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization. Contact hall@coreservlets.com for details.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Agenda Reading HTTP request headers Building a table of all the request headers Understanding the various request headers Reducing download times by compressing pages Differentiating among types of browsers 4 A Typical HTTP Request GET /search-servlet?keywords=servlets+jsp HTTP/1.1 Accept : image/gif, image/jpg, */* Accept-Encoding : gzip Connection : Keep-Alive Cookie : userID=id456578 Host : www.somebookstore.com Refere : http://www somebookstore com/findbooks htm Referer : http://www.somebookstore.com/findbooks.html User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) It shouldn’t take a rocket scientist to realize that you need It shouldn t take a rocket scientist to realize that you need to understand HTTP to be effective with servlets and JSP 5
Background image of page 2
Reading Request Headers (Methods in HttpServletRequest (Methods in HttpServletRequest) General getHeader (header name is not case sensitive) getHeaders getHeaderNames Specialized getCookies getAuthType and getRemoteUse getAuthType and getRemoteUser getContentLength getContentType getDateHeader getIntHeader Related info getMethod, getRequestURI , getQueryString, getProtocol 6 Checking For Missing Headers HTTP 1.0 All request headers are optional HTTP 1.1 Only Host is required Conclusion Alway check that request getHeader is non null before Always check that request.getHeader is non-null before trying to use it String val = request.getHeader( " Some-Name " ); if (val != null) { } 7
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Making a Table of All Request Headers @WebServlet("/show-request-headers") public class ShowRequestHeaders extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Content-Type, PrintWriter, docType defn, etc.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/13/2011 for the course CSE 474 taught by Professor Ömerkorçak during the Spring '11 term at Marmara Üniversitesi.

Page1 / 13

04-Request-Headers - 2010 Marty Hall Handling the Client...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online