• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Response.sendRedirect is throwing illegalStateException

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
}
}
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("").
 
reply
    Bookmark Topic Watch Topic
  • New Topic