| Author |
Java Strangeness...
|
Scott Batchelor
Greenhorn
Joined: Jul 07, 2003
Posts: 11
|
|
Ok here is a scenario I am seeing. I am debugging my app and I am using this block of code to do a redirect: try { response.sendRedirect(url); LOG.debug("Redirect URL = " + url); } catch (IOException e) { // } When I step throught his code it actually hit the line: response.sendRedirect(url); And the url variable is correct in the logs. But it doesnt send the app anywhere just continues on. Any thoughts. I hope this isnt to vague but I am stumped as to what could be causing this. Scott
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
The sendRedirect method actually doesn't perform the redirect in-line. What it does is to set up the headers on the response to instruct the user agent (usually a browser) to initiate a new request using the header information. So you won't see anything happen until after your servlet completes and the response is sent back to the browser. hth, bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Pavel Halas
Ranch Hand
Joined: Jul 05, 2003
Posts: 35
|
|
I give you a good advice. Never use empty catch block. You're going to tear your hair one day... This is MUCH better:
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
|
P.S. This would have been better asked in the Servlets forum. Nudge. Wink.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
Actually, to address the exception issue, here's the idiom I use all over the code: If an exception is thrown, you rarely want to eat it and just move on -- even if you have logged it. That's the purpose of the ServletException and why it can wrap a root cause exception (in this case the IOE). hth, bear
|
 |
 |
|
|
subject: Java Strangeness...
|
|
|