This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
There are two primary means to do this: If you want the browser to create a new request in which to display the page, you would redirect to index.html using the sendRedirect() method of the response. If you want to display the page in the context of the same request (which you would want to do if the page depends upon anything your servlet has placed into request -- unlikely in this case since your target page is an html page and not a JSP), you would forward using a RequestDispatcher instance. hth, bear [ March 05, 2002: Message edited by: Bear Bibeault ] [ March 05, 2002: Message edited by: Bear Bibeault ]
Chris, that error message means that output has already been comitted to the response. Once that happens, you can no longer redirect. Your code should decide whether a redirect is necessary prior to producing any output. If you think about it for a minute this makes sense. If you have written output to the response AND tell the browser to display a file such as your index.html, which should it show? If your intent is to emit some output, and THEN append some output from an html or JSP file to that, you would use neither a redirect nor a forward, but rather an include (see getRequestDispatcher() on the request). hth, bear
Joined: Sep 29, 2001
Yeah I found what I was doing wrong. Thanks for your help!