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

8.7 Redirecting the Client

The response object provides a function for returning an HTTP redirect. The sendRedirect() function takes an string containing a URL, and sets the response to an HTTP Temporary Redirect directing the client to the URL. The code sample below redirects a client to the Rogue Wave Web site:

The Servlet Specification allows the servlet container to transmit the response to the client as soon as the servlet calls sendRedirect(). Therefore, the servlet should not alter the response after calling sendRedirect(), since the client may not receive the changes.

The sendRedirect() function does not rewrite the URL to include session information. If the servlet uses URL rewriting to track sessions, the servlet should rewrite the URL before calling sendRedirect(). The sample below forwards the client to another servlet in the same context while preserving session information:

Note that the sendRedirect() function sends an HTTP redirect message to the client. A servlet can also directly retrieve content from another location, or forward a request to another servlet in the container. For details on forwarding a request, see Section 8.8.

Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.