Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.IllegalStateException: Cannot forward. Response already committed

800478Sep 25 2008 — edited Sep 25 2008
In our requirement we need to display the images on a JSP and these images are stored in database. I can get the image from database uwing rs.getBinaryStream() and I can see the image on the jsp page.
but I get the exceptions on server console
java.lang.IllegalStateException: Cannot forward. Response already committed.
and on jsp I see two kinds of exception
  1)   Original Exception:
        Error Message: Cannot forward. Response already committed.

    2)  Error Page Exception:
         Error Message: SRVE0199E: OutputStream already obtained
         Error Code: 0
Servlet code :
                       ResultSet rs =stmt.executeQuery("select Q1IMG from Q1A1 where Q1A1='qw1'");
	                String imgLen="";
	               if(rs.next()){
	      	               imgLen = rs.getString(1);  
	                 }  
		        rs =stmt.executeQuery("select Q1IMG from Q1A1 where Q1A1='qw1'");
			if(rs.next()) { 
			int len = imgLen.length();
		        byte [] rb = new byte[len];
		        InputStream readImg = rs.getBinaryStream(1);
		        int index=readImg.read(rb, 0, len);  
		        log.debug("index "+index);
		        rs.close();
		        response.getOutputStream().write(rb);
		        response.getOutputStream().flush();
		}
what could be the reason? how we can avoid them?
could some one please give me solution.

Thanks
Sumant
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2008
Added on Sep 25 2008
1 comment
297 views