Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Buffer problem?

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about making a call to clear the buffer before you redirect the output?
------------------
- Jessica Bradley
HP Bluestone
 
Ben Roy
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how to clear the buffer.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
Use jsp:forward instead of sendRedirect() may clear the problem. Hope it helps.
 
Ben Roy
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I do a jsp:forward to a dynamic address? I was thinking the tags had to be static.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic