{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 R t H d Request Headers Originals of Slides and Source Code for Examples: http://courses coreservlets com/Course-Materials/csajsp2 html 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 Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6. , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization. Contact [email protected] for details.
Background image of page 1

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

View Full Document Right 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 A t i / if i /j */* Accept : image/gif, image/jpg, */* Accept-Encoding : gzip Connection : Keep-Alive Cookie : userID=id456578 Host : www.somebookstore.com Referer : http://www somebookstore com/findbooks html : 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) General tH d (h d i t iti ) getHeader (header name is not case sensitive) getHeaders getHeaderNames Specialized getCookies 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 O l i i d Only Host is required Conclusion Always check that request getHeader is non null before 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 Document Right 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.
  • Spring '11
  • ÖmerKorçak
  • Internet Explorer, World Wide Web, Web browser, Hypertext Transfer Protocol, Firefox, request headers

{[ snackBarMessage ]}