File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jsp:forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:forward" Watch "jsp:forward" New topic


Rex Rock
Ranch Hand

Joined: Jun 25, 2001
Posts: 82
Hi people,
I have a form, where I collect details from user, if everything is fine, take him to a new page, thank him for submitting details.
I would like to take the user to another page,after displaying the thank you page for 2 seconds (say).
I tried <jsp:forward page="http://localhost:8080/newpage.jsp" />.
I get the following error, Error: Attempt to clear a buffer that's already been flushed
Please shed some light here..
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63839

You cannot forward once some output has been sent as part of the response. The best way to achieve what you are attempting is to either use the HTML meta tag to cause a redirect after your 2 seconds are up:
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=whatever.jsp">
or to use a Javascript timeout to cause the redirect of you need more programmatic control.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: jsp:forward
jQuery in Action, 3rd edition