You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Parks <da...@yahoo.com> on 2010/07/29 21:04:09 UTC

Tomcat stops loading page half way through on runtime exception

I'm getting a runtime NullPointerException (just code in dev I'm working on).
But I notice that Tomcat only loads half the page and stops roughly around the 
exception point (+/- some buffer amount it looks like).
I'd much prefer a more consistent response (at this time, just the standard 
exception page).

Is there a way to ensure the exception page is displayed on exceptions (or in 
the future to ensure that the defined pretty error page is displayed)?

I really just want to avoid the potential of half-loaded pages, they look 
horrid.

Thanks,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat stops loading page half way through on runtime exception

Posted by David Parks <da...@yahoo.com>.
Ok, I'm with it now I think, the two factors are the use of flush() (I'm not using that anywhere) and the buffer size, I probably exceed the buffer before the exception occurred.

You did call me out on my poor best practices, I do have too much unchecked code in my JSP, so thanks for pointing that one out, I'll improve those practices.

Thanks Chris and Charles for pointing me in the right direction!
David


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, July 30, 2010 8:14 AM
To: Tomcat Users List
Cc: Caldarale, Charles R
Subject: Re: Tomcat stops loading page half way through on runtime exception

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

On 7/29/2010 3:14 PM, Caldarale, Charles R wrote:
>> From: David Parks [mailto:davidparks21@yahoo.com]
>> Subject: Tomcat stops loading page half way through on runtime 
>> exception
>>
>> I'd much prefer a more consistent response (at this time, just the 
>> standard exception page).
> 
> What is "the standard exception page"? If you're referring to the 
> standard error page Tomcat generates, it can't send it if your webapp 
> has already committed all or a portion of the response (via flush(), 
> for example). You shouldn't be doing that until you know you're going 
> to be able to complete the processing of the request.

+1

Ideally, nothing during response generation should suffer a fatal error like this. Usually when this kind of thing happens, it's because someone is packing way too much logic into a JSP that really should be a servlet-then-JSP model.

>> Is there a way to ensure the exception page is displayed on 
>> exceptions (or in the future to ensure that the defined pretty error 
>> page is displayed)?
> 
> Fix your webapp to not send partial responses.  Nothing Tomcat can do if you've already committed the response; there's no way to recall what you've already sent.

+1

The other option is to use a /huge/ buffer, which is bad practice for a stable webapp.

"8k ought to be enough for anyone" ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxS7CkACgkQ9CaO5/Lv0PBoXgCfY7Q9Z6bhTaWPi6qBh6crkA8z
gaAAoKSg7RI/JO/YAAmIHOrVQL00alRc
=Affv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat stops loading page half way through on runtime exception

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

On 7/29/2010 3:14 PM, Caldarale, Charles R wrote:
>> From: David Parks [mailto:davidparks21@yahoo.com]
>> Subject: Tomcat stops loading page half way through on runtime
>> exception
>>
>> I'd much prefer a more consistent response (at this time, 
>> just the standard exception page).
> 
> What is "the standard exception page"? If you're referring to the
> standard error page Tomcat generates, it can't send it if your webapp
> has already committed all or a portion of the response (via flush(), for
> example). You shouldn't be doing that until you know you're going to be
> able to complete the processing of the request.

+1

Ideally, nothing during response generation should suffer a fatal error
like this. Usually when this kind of thing happens, it's because someone
is packing way too much logic into a JSP that really should be a
servlet-then-JSP model.

>> Is there a way to ensure the exception page is displayed 
>> on exceptions (or in the future to ensure that the defined
>> pretty error page is displayed)?
> 
> Fix your webapp to not send partial responses.  Nothing Tomcat can do if you've already committed the response; there's no way to recall what you've already sent.

+1

The other option is to use a /huge/ buffer, which is bad practice for a
stable webapp.

"8k ought to be enough for anyone" ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxS7CkACgkQ9CaO5/Lv0PBoXgCfY7Q9Z6bhTaWPi6qBh6crkA8z
gaAAoKSg7RI/JO/YAAmIHOrVQL00alRc
=Affv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat stops loading page half way through on runtime exception

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: David Parks [mailto:davidparks21@yahoo.com]
> Subject: Tomcat stops loading page half way through on runtime
> exception
> 
> But I notice that Tomcat only loads half the page and 
> stops roughly around the exception point

Tomcat doesn't load pages, it sends them; the browser loads pages.

> I'd much prefer a more consistent response (at this time, 
> just the standard exception page).

What is "the standard exception page"?  If you're referring to the standard error page Tomcat generates, it can't send it if your webapp has already committed all or a portion of the response (via flush(), for example).  You shouldn't be doing that until you know you're going to be able to complete the processing of the request.

> Is there a way to ensure the exception page is displayed 
> on exceptions (or in the future to ensure that the defined
> pretty error page is displayed)?

Fix your webapp to not send partial responses.  Nothing Tomcat can do if you've already committed the response; there's no way to recall what you've already sent.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org