The error "java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client." was occur due to the jsp sendredirect method was called in between the html code implemention.
Example:
To solve this problem :
you can make is to be sure that this code(jsp redirection) occurs before any html is written.
Example :
<%
while (result.next()) {
if (result.wasNull()) {
response.sendRedirect("login.jsp");
}
else {
response.sendRedirect("home.jsp");
}
}
%>
<html>
<body>
.......
</body>
</html>
I hope this will be help for solve the java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client exception.
Example:
<html>
<body>
<%
while (result.next()) {
if (result.wasNull()) {
response.sendRedirect("login.jsp");
}
else {
response.sendRedirect("home.jsp");
}
}
%>
</body>
</html>
To solve this problem :
you can make is to be sure that this code(jsp redirection) occurs before any html is written.
Example :
<%
while (result.next()) {
if (result.wasNull()) {
response.sendRedirect("login.jsp");
}
else {
response.sendRedirect("home.jsp");
}
}
%>
<html>
<body>
.......
</body>
</html>
I hope this will be help for solve the java.lang.IllegalStateException: Can't sendRedirect() after data has committed to the client exception.
No comments:
Post a Comment