3 Replies Latest reply on Apr 2, 2002 11:22 AM by Jules Gosnell


    Erik Turesson Novice


      I am using Jboss 3.0 beta2, ie the latest from CVS and I use Jetty as webserver/servlet engine.

      I have a jsp page in which I want to return an image to the client.
      Thats the only purpose of this page. I use it in my htmlpages to
      specify the source for my images.

      I have one static method in a helper class. It look like this.

      public static void downloadFile(HttpServletResponse response,
      byte[] b,
      String contentType){
      response.getOutputStream().write(b, 0, b.length);
      }catch(Exception e){
      System.out.println("downLoadFile " + e);

      My call in my jsp page looks lik this.

      image is an internal object of mine.
      image.getImage() returns byte[] and image.getContentType() returns a
      I have not used the response object before in my page or called the
      getWriter method.

      My page works fine except for that I recieve a IllegalStateException
      every time.
      The stacktrace tells that it occures in the following line of code.

      The image is however returned fine to the client.

      What is wrong?

      /Erik Turesson

        • 1. Re: IllegalStateException
          Neal Sanche Newbie

          This seems to be a recent thing. I was not getting
          the IllegalStateExceptions on a JBoss 3.0 build
          from March 20th, and only noticed them today (the 25th).
          The problem seems to be that the getOutputStream
          method in the ServletResponseWrapperInclude
          simply throws an exception now. There is a getWriter()
          method, and perhaps if you use that instead, it might
          work without the exception. Is getOutputStream
          deprecated or something?


          • 2. Re: IllegalStateException
            Neal Sanche Newbie

            I found the line that emits the warning, and I think it's probably going to be modified by the Jetty folks, and whenever the latest Jetty gets refreshed in the JBoss CVS this warning
            will probably go away. There's a line in org.mortbay.jetty.servlet.Dispatcher that says Code.warn(e) that can be commented out to stop the exceptions. It seems there's code in there to handle the exception by creating a WriterOutputStream...

            hope this helps... Let's hope this is very temporary.


            • 3. Re: IllegalStateException
              Jules Gosnell Novice

              Post this to jetty-discuss@yahoogroups.com - they are very helpful.