[ Team LiB ] Previous Section Next Section

Q&A

Q1:

I cleared the buffer, so why do I still see part of the old page?

A1:

The buffer was probably already flushed. You might need to increase the size of the output buffer, or if you really don't know how big to make it, set autoFlush to false. Be careful, though. You need to flush the buffer yourself if you set autoFlush to false.

Q2:

I turned off autoFlush, so why do I still see part of the old page?

A2:

You probably included this page from another one. Whenever you include another page at runtime by using the include method of pageContext, the JSP engine automatically flushes the buffer for the including page. If you want to prevent this from happening, set the flush parameter of the include method to false.

Q3:

Why do I get an error when I try to forward to another page or include another page?

A3:

The first thing to check is that you entered the correct filename and that you are using a relative path. If you just enter a filename with no directory names, that file should be in the same directory as the JSP that is including it or forwarding to it. Assuming that the filename is correct, the other thing to check is that the target page compiles correctly on its own. If you forward to or include a bad page, you'll get an error. Try accessing the page manually and see whether there is an error.

Q4:

When I include or forward to another page, why do I get an exception referring to the buffer?

A4:

When you forward to another page, the JSP engine attempts to clear the output buffer. If the buffer has already been committed, you'll get an error. When you include another page, the JSP engine automatically flushes the output buffer. So if you include another page and then try to forward, you're almost assured of getting an error. You need to rethink your design to avoid these situations.


    [ Team LiB ] Previous Section Next Section