aspose file tools*
The moose likes JSP and the fly likes Buffer problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Buffer problem?" Watch "Buffer problem?" New topic
Author

Buffer problem?

Ben Roy
Ranch Hand

Joined: Nov 01, 2000
Posts: 70
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!
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

what about making a call to clear the buffer before you redirect the output?
------------------
- Jessica Bradley
HP Bluestone


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Ben Roy
Ranch Hand

Joined: Nov 01, 2000
Posts: 70
I'm not sure how to clear the buffer.
Frank Lin
Ranch Hand

Joined: Jan 26, 2001
Posts: 76
Ben,
Use jsp:forward instead of sendRedirect() may clear the problem. Hope it helps.
Ben Roy
Ranch Hand

Joined: Nov 01, 2000
Posts: 70
How do I do a jsp:forward to a dynamic address? I was thinking the tags had to be static.
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Buffer problem?