-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chuck,
On 6/26/2009 12:27 PM, Caldarale, Charles R wrote: >> From: Jonathan Mast [mailto:jhmast.develo...@gmail.com] Subject: >> Null value in response.sendRedirect() causes original url to be >> invoked 20 times >> >> A null value in bounce_url is causing the original Request url to >> be invoked exactly 20 times, rather than dying with >> NullPointerException: > > "Doctor, doctor, it hurts when I do this!" > > Well, stop doing it. > > All a redirect does is set the Location header with the value you > specify and return a 302 status to the client. Since the Location > header has an empty value, the client properly interprets that as a > relative redirect to the current page. Your client apparently gets > tired of waiting for that page to change its mind and return > something useful after 20 consecutive times, so it quits. > > The bug is all yours. One could argue that response.sendRedirect(null) ought to throw some kind of exception. The javadoc says that sendRedirect throws: "java.lang.IllegalStateException - If the response was committed or if a partial URL is given and cannot be converted into a valid URL" I would say that null cannot be converted into a valid URL, and so throwing IllegalStateException is a reasonable behavior here. The HTTP RFC says "The temporary URI SHOULD be given by the Location field in the response.". Though RFC-SHOULD is more of a recommendation than anything else, it's obvious that a redirect without a Location header is pretty stupid. It would be nice if Tomcat throw an exception when attempting to send a null redirect, since the HTTP response that /does/ get created is pretty useless and almost certainly a bug in the webapp. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkpE+9kACgkQ9CaO5/Lv0PDkaACfUWfw9qm85mNzB5kHotEdQ307 gxgAn3YsDZbvQsCB3BrgjHcLjoGVvgUj =LF8p -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org