• Post Reply Bookmark Topic Watch Topic
  • New Topic

<jsp:forward> error message  RSS feed

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im my JSP code, I check for a condition and call jsp:forward
when the condition is true. However I am getting an error message in Tomcat that says:

The code looks like this:

How do I fix this ?
Thanks
Pho
 
kichu kichu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
1)Declare a flag.
2)When your condition becomes true,Set a value for the flag.
3)Check for that value and then forward the page.
Code will look something like this
Flag fl = 0;
When condition becomes true set it to 1.
Then check for new value i.e
if(fl == 1)
{
<jsp:forward page = "name of page" />
}

This has gotta work.
If you have any doubts please mail.
bye,
kichu.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's probably because you have already have HTML or out.println("") statements before you say <jsp:forward>.

This is not allowed, since your first page has already commited the output stream (it has opened it and written something, probably "<html>....")

Although this should throw an IllegalStateException, so I am only guessing. But when forwarding doesn't work, it's usually because output has already been written, which might be your problem, based on the error message.

Try buffering your output. I think I have tried this before, but Tomcat (and I assume others) don't always implement buffering correctly, so you may have trouble getting it to work.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
it cannot possibly work because the JSP file that I am editing is an include file within another JSP file. Aarrghhh!
Pho
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!