• Post Reply Bookmark Topic Watch Topic
  • New Topic

pagebuffer Flushed! Error page redirect to Late!!

 
M. Christensen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I've been hitting my head on this one for a while, and I'm just not satisfied with any of the solutions I've come up with. Let me give you all the problem, and let me know which solution sounds least disgusting; or if you know a better idea, lay it out for me!
PROBLEM:
I'm outputing a rather lengthy page, that can in some unusual cases be nearly a meg in size. If an error occurs and an exception is thrown while I'm assembling the jsp page, it gets redirected to the error page. Unfortunately the buffer has been flushed and part of the html has already been sent to the client. So I end up with the first part of my broken page that was generated before the error occured, with the error page tacked onto the end displayed in my browser.
SOLUTION 1:
Increase the page buffer size, or set the buffer size to unlimited length:

-I don't like this one, because I don't like the idea of increasing the memory usage per request to that extreame...A FULL MEG??!! the default is something like 8kb. Also the entire page must be assembled before I even start pushing it down the pipe to the client.
SOLUTION 2:
Wrap the whole thing in a try catch block; catch the exception myself, put the errormessage and exception in the session, and response.sendRedirect() to the error page.

--works the same as 2
SOLUTION 4:
Use the try catch block idea, but instead output a javascript function that is fired with body onload event. This results in the half rendored page showing for a split second, then the browser redirects to the error page.
--This actually works, but man it feels lame.
SOLUTION 5:
Your a we bit obsessive, go to bed and just choose something in the morning.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why you can't hold all of your data in a StringBuffer and/or byte array and only write them out if there were no errors.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!