Forums Register Login

Buffer problem?

+Pie Number of slices to send: Send
This is a little complicated to explain, so please bear with me.
Short list of steps of what is happening:
1) On the main page (a .jsp), click the login button which launches a new browser window with the login pages
2) Type in information and submit
3) The page reloads, checks the authentication info (via a javabean), and if successful, uses a response.sendRedirect() to forward it to a close page
4) The close page uses javascript to send the main window to a new page and close itself
Here's where the problem comes in. When the new page loads in the main window, I end up with the entire body of the login page, plus the text at the end of this message, plus the page it is supposed to be displaying. All in one. It seems like on the redirect it is sending all of the html to the buffer, even though I redirected before the html, and then the next page you go to it is writing it all to the screen.
First thought whenever the buffer comes up is "flush the buffer!" But I don't want to send that information at all...that's why I have a redirect. As a side note, I did try to flush the buffer, and it acted just the same. Here's the text that is inserted after the body of the login page and before the body of the page it is redirecting to:
HTTP/1.1 200 OK Date: Wed, 12 Dec 2001 21:25:29 GMT Server: Apache/1.3.12 OpenSSL/0.9.6a (Unix) ApacheJServ/1.1 mod_jk Servlet-Engine: Tomcat Web Server/3.2.3 (JSP 1.1; Servlet 2.2; Java 1.3.1_01; SunOS 5.6 sparc; java.vendor=Sun Microsystems Inc.) Keep-Alive: timeout=5, max=14 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=ISO-8859-1 ffb
Also I should note that if you refresh the page it comes up correctly. Some other links on the site will sometimes (apparently at random) display the wrong page or parts of other pages. Again, a refresh always fixes them.
HELP!
+Pie Number of slices to send: Send
what about making a call to clear the buffer before you redirect the output?
------------------
- Jessica Bradley
HP Bluestone
+Pie Number of slices to send: Send
I'm not sure how to clear the buffer.
+Pie Number of slices to send: Send
Ben,
Use jsp:forward instead of sendRedirect() may clear the problem. Hope it helps.
+Pie Number of slices to send: Send
How do I do a jsp:forward to a dynamic address? I was thinking the tags had to be static.
+Pie Number of slices to send: Send
 

Originally posted by Ben Roy:
I'm not sure how to clear the buffer.


call out.clear() or out.clearBuffer()
JspWriter.clear() will throw an IOException if the buffer has already been flushed to show you that something has already been written and flushed to the stream.
JspWriter.clearBuffer() will not throw an IOException even if the buffer has already been flushed. It simply clears the current buffer and returns.
------------------
- Jessica Bradley
HP Bluestone
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1167 times.
Similar Threads
RequestDispatcher include..
Firefox doesn't send JSESSIONID in GET applet-jar request
How Do You Send text/html After Sending A ServletOutputStream File To The Client?
How to See the HTTP Message Exchange between browser and Tomcat?
redirecting servlet fails with embedded jsessionId
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:29:31.