Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Servlet Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

8.3 Creating HTTP Headers

An rwsf::HttpServletResponse contains a collection of headers that the servlet container uses for the response to the client. The response provides the function setHeader() for adding free-form text headers, the function setDateHeader() for creating headers that contain a date, and the function setIntHeader() for creating headers that contain a number. The response also provides named accessors for the Content-Type and Content-Length headers.

The servlet container does not include a Content-Type header by default. A response must set the Content-Type to the MIME type of the content in the payload.

The following code uses a named accessor to set the Content-Type of a response to text/xml:

The code sample below adds a nonstandard HTTP header to a response:

The response provides a setDateHeader function for creating a header from an rwsf::DateTime object. The code sample below uses the setDateHeader() function to create an Expires HTTP header with a time two days from the present. The sample below creates an rwsf::DateTime with the current time, adds 48 hours to the time, converts the time to HTTP date format, then adds the header to the request:



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.