| Author |
response.sendRedirect() from Dynamic Include
|
srividhya umashanker
Greenhorn
Joined: Jun 26, 2003
Posts: 4
|
|
hi group, I have a problem while using response.sendRedirect() in my Jsp Page. Scenario: I have a Jsp page, which has static and dynamic includes In one of the dynamic include file, i am using response.sendRedirect() to redirect to another page. A runtime IllegalStateException is thrown in this case, as It says the response has already been committed. But if the response.sendRedirect() works fine when used directly in the main JSP Page. that too.. when the buffer size is increased Questions 1. What is the reason behind this exception. 2. what would be a better Solution this problem? thanx in advance regards srividhya
|
 |
rahul V kumar
Ranch Hand
Joined: May 20, 2003
Posts: 82
|
|
"sendRedirect() and sendError() methods will have the side effect of committing the response, if it has not already been committed, and terminating it. No further output to the client should be made by the servlet after these methods are called. If data is written to the response after these methods are called, the data is ignored." But if you have commited the response and have called sendRedirect() method, then that will result in IllegalStateException. You can use this method "response.isCommitted()" to check if response is already commited or not. Hope this helps.
|
 |
 |
|
|
subject: response.sendRedirect() from Dynamic Include
|
|
|