The Workshop is designed to help you review what you have learned and help you to further increase your understanding of the material covered in this hour.
How do you get to the raw content of a request?
When is the content of a response buffer sent to a client?
What are a few common methods used to identify sessions?
You can get the body of a request by using the getReader or getInputStream methods of a request object. There's no way provided by the servlet request objects to obtain the raw HTTP request. Fortunately, you will never need to access this information directly in a Web application, since ServletRequest and HttpServletRequest make the parsed information easily available.
A number of activities can cause the content of a buffer to be sent. In most cases, the service method ends or the amount of content specified by setContentLength has been written to the buffer. The container will also send the content when the buffer is filled or when the method flushBuffer is called. Finally, the content of a buffer will be sent if the sendError or sendRedirect methods of the response object are invoked.
Write a servlet that displays all of the information about an HttpServletRequest.
Create a simple servlet that receives a username from a form, stores the name in a context attribute and forwards to another servlet that displays the name.
Create a simple servlet that stores a username as part of a cookie. Write a companion servlet that displays the username retrieved from the cookie.