www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > Java
    (NOT JavaScript!)

    Java
    (NOT JavaScript!)
    For discussion of the Java programming language as it applies to the Web ( Not JavaScript ).

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 07-31-2006, 03:33 AM
    aisyah aisyah is offline
    Registered User
     
    Join Date: Oct 2003
    Location: Malaysia
    Posts: 20
    [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
    Reply With Quote
      #2  
    Old 08-01-2006, 09:32 PM
    Khalid Ali's Avatar
    Khalid Ali Khalid Ali is offline
    Super Moderator
     
    Join Date: Dec 2002
    Location: Calgary, Canada
    Posts: 8,949
    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
    Reply With Quote
      #3  
    Old 08-02-2006, 10:03 PM
    aisyah aisyah is offline
    Registered User
     
    Join Date: Oct 2003
    Location: Malaysia
    Posts: 20
    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
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:13 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.