|
|||||||
| Java (NOT JavaScript!) For discussion of the Java programming language as it applies to the Web ( Not JavaScript ). |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
[Urgent]Read file and display to JSP using servlet
I have a problem in read and display my image file in servlet
Below is my code ... Any help if tjis code is not correct. OutputStream out=response.getOutputStream(); FileInputStream fin=null; BufferedInputStream fBuf=null; try { fin=new FileInputStream("logo.gif"); fBuf=new BufferedInputStream(fin); final int BufferLen=2048; byte[] buf=new byte[BufferLen]; int bytesRead; while(-1!=(bytesRead=fBuf.read(buf,0,buf.length))) { out.write(buf,0,bytesRead); } if (out!= null) { out.flush(); out.close(); } } catch(FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch(Exception e) { ; e.printStackTrace(); } finally { if (fBuf!=null) fBuf.close(); if (fin!=null) fin.close(); } thanks - AIsyah
__________________
aisyah |
|
#2
|
||||
|
||||
|
you must post the errors that you are getting..
__________________
Cheers Khalid Message Posting Guidelines In These Forums, Please read these before posting any question. Web site: webapplikations.com Web Resources Page:Web Resources |
|
#3
|
|||
|
|||
|
I just wonder why message from log said that :
StandardWrapperValve[org.apache.catalina.INVOKER.TestData]: Servlet.service() for servlet org.apache.catalina.INVOKER.TestData threw exception ClientAbortException: java.net.SocketException: Connection reset at org.apache.coyote.tomcat4.OutputBuffer.realWriteBytes(OutputBuffer.java:367) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:398) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:318) at org.apache.coyote.tomcat4.OutputBuffer.writeBytes(OutputBuffer.java:395) at org.apache.coyote.tomcat4.OutputBuffer.write(OutputBuffer.java:382) at org.apache.coyote.tomcat4.CoyoteOutputStream.write(CoyoteOutputStream.java:64) at org.apache.coyote.tomcat4.CoyoteOutputStream.write(CoyoteOutputStream.java:58) at TestData.doGet(TestData.java:112) what actually this error said ... ? tq |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|