File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes jsp:forward problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp:forward problem" Watch "jsp:forward problem" New topic
Author

jsp:forward problem

ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
Hello everybody! I am new to JSP and I am having problems with the <jsp:foward> tag. Here is my situation:
I am updating records from a database. The two updates are 1) Modify a db record or 2) delete it.
After a successful update i then try to do a jsp foward so that i can go back to the previous page. I always get an error telling me that I cannot clear a buffer which has already been flushed. This is very depressing. It works only if i call jsp foward at the top of the page. I read somewhere that one would normally do a jsp forward before writing to the out object. What's this about??
Please help!!


In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
June
Greenhorn

Joined: Aug 16, 2001
Posts: 24
What is your jsp forward stmt?
something like this:
<jsp:forward page="test.jsp" flush="true"/>

JQ
ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
Sorry June, if i do as you suggest I get an error. Tomcat is complaining about the flush attribute: can flush=true be used with jsp forward? i thought it could only be used with include? I am using Tomcat 3.2.3.
Thanks anyway
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
To answer your question: "<b>I read somewhere that one would normally do a jsp forward before writing to the out object. What's this about??</b>"
You can't forward a jsp page (or a servlet, but they are ultimately the same thing in the end) once the output stream has been committed. (flushed) What this means is that you cannot write to the client's browser and then call the jsp forward tag. (I think)
Try not outputting anything on the jsp page that is using forward.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, in servlets and JSP, output can not be sent to the client before forwarding. That's why you are not getting the error when you do the forwarding as the first thing.
Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:forward problem
 
Similar Threads
IllegalStateException of pageContext.forward( )
What is the difference between Submit and Foward in jsp
RequestDispatcher does not update URL in Address Bar
How to show only 10 entries in a jsp-page?
Login Page creation help