java - JSP: "getOutputStream() has already been called for this response" get exception while display image on screen -
i getting exception while fatch image database , display image on screen. please help me solve error..
int questionid ; connection conn = null; conn= new dbfunction().getconnect(); statement stmt = conn.createstatement(); questionid=4; seek { conn.setautocommit (false); // image database blob img ; byte[] imgdata = null ; string req = "select img questionlist queid = " + questionid ; resultset rset = stmt.executequery ( req ); while (rset.next ()) { img = rset.getblob("img"); imgdata = img.getbytes(1,(int)img.length()); } // display image response.reset(); response.setcontenttype("image/gif"); outputstream o = response.getoutputstream(); o.write(imgdata); o.flush(); o.close(); } grab (exception e) { e.printstacktrace(); }
let me know wrong ?
it not improve practice write java
codes within jsp jsp calls printwriter
default. scriptlets not advised on decades . seek moving code java file , preferably servlet.
also not improve alternative store images database , seek utilize diskspace instead. far question seek out.clear()
see how avoid java code in jsp-files?
java sql jsp exception
No comments:
Post a Comment