• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Illegal State Exception

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I frequently get the following message while executing my servlets:

java.lang.IllegalStateException
at org.apache.coyote.tomcat4.CoyoteResponseFacade.sendRedirect
(CoyoteResponseFacade.java:338)


There is a simple Javascript in the JSP that calls the method on the servlet when the button on the screen is clicked. The method throws in a few attributes in the session and calls the following line:

getResponse().sendRedirect("KCSSChangeTitle.jsp");

This is where I get the IllegalStateException.
We are using Tomcat version 4.1.30 running on Windows 2000 server.
Does anyone know what could be causing this?
Thanks!!
P.S: The other messages on the board about IllegalStateException are about commiting response but the message I get is a little different; hence I decided to start a new thread.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An IllegalStateException on a sendRedirect is almost always caused by a call to sendRedirect after data has already been sent to the browser.

If you have any output (including setting headers) before the sendRedirect, you will see this exception.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by S Zaidi:
There is a simple Javascript in the JSP that calls the method on the servlet when the button on the screen is clicked. The method throws in a few attributes in the session and calls the following line:

getResponse().sendRedirect("KCSSChangeTitle.jsp");


BTW, the above is not JavaScript, it is scriptlet and will be executed by the server hence the Exception.

You should only use such statement in the beginning of your JSP file before any output to web browser.
 
reply
    Bookmark Topic Watch Topic
  • New Topic