• Post Reply Bookmark Topic Watch Topic
  • New Topic

Response.sendRedirect is throwing illegalStateException  RSS feed

 
Sue Kale
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 3 jsp files
1. Login.jsp
2. MainMenu.jsp
3.ReLogin.jsp
The MainMenu.jsp file Checks the loginName and password against a database and if it is not found sends a response.sentRedirect("/test/Relogin.jsp"). It was working fine in Tomcat3.0 but after moving to Tomcat4.0 it is giving an illegalStateException. Please help.
This is the piece of code (SS_LoginStatus is one of the session object)
else
{
session.setAttribute("SS_LoginStatus", "Invalid");
response.sendRedirect("http://localhost:8080/test/ReLoginScreen.jsp");
}
}
else{
session.setAttribute("SS_LoginStatus", "Blank");
response.sendRedirect("http://localhost:8080/test/ReLoginScreen.jsp");
}
}
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch "Dream"!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
JSP Forum Bartender
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Javadocs for the sendRedirect method you will see that it states that you get IllegalStateException if the response has already been committed. So it looks like something in your code is sending enough text to the response that the buffer gets flushed.
Bill
 
Sue Kale
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my MainMenu.jsp file i get the user's login from request.getParameter and if it is valid I update the count in the Database.
The else statement i.e.not a valid user sends the response.redirect to reLogin page.
Do I need change the if/else i.e. not update users table in Database in the if statement ???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Dream", my post asking you to modify your display name was not a suggestion and is not optional. Please modify your display name to conform to Ranch standards prior to your next post. Failure to comply may result in your account being closed.
thanks,
Bear
JSP Forum Bartender
 
Sue Kale
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for your help. I was able to solve the problem (illegalState Exception by adding a return statement after the response.sendRedirect("").
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!