Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:forward problem

 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
June
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your jsp forward stmt?
something like this:
<jsp:forward page="test.jsp" flush="true"/>
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic