unable to load images from a webpage


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: unable to load images from a webpage

  1. #1
    palash kasodhan Guest

    unable to load images from a webpage


    I am developing a web-proxy server, which intercepts requests from the
    browser, contacts the remote server and relays the response back to
    the browser.However I have some problem with the way images are getting
    displayed.Some images dont get displayed at all while others may be
    half loaaded only.There is no problem with getting the text in the page
    Just have a look at my code below and point out the potential problem :



    RemoteUrl = new URL( url_string.trim() ) ;
    ClientIn = new BufferedInputStream( RemoteUrl.openStream()) ;
    outstream = new BufferedOutputStream( ClientSocket.getOutputStream() ) ;

    byte[] buf = new byte[1024];
    int len = 0;
    try{

    while ((len = ClientIn.read(buf)) >= 0)
    outstream.write(buf,0,len);






  2. #2
    Paul Clapham Guest

    Re: unable to load images from a webpage

    Here's what the API documentation says about that "read" method:

    Returns:
    the total number of bytes read into the buffer, or -1 if there is no more
    data because the end of the stream has been reached.

    You are not comparing to -1.

    PC2

    "palash kasodhan" <palashkasodhan@yahoo.com> wrote in message
    news:3bf05884$1@147.208.176.211...
    >
    > I am developing a web-proxy server, which intercepts requests from the
    > browser, contacts the remote server and relays the response back to
    > the browser.However I have some problem with the way images are getting
    > displayed.Some images dont get displayed at all while others may be
    > half loaaded only.There is no problem with getting the text in the page
    > Just have a look at my code below and point out the potential problem :
    >
    >
    >
    > RemoteUrl = new URL( url_string.trim() ) ;
    > ClientIn = new BufferedInputStream( RemoteUrl.openStream()) ;
    > outstream = new BufferedOutputStream( ClientSocket.getOutputStream() ) ;
    >
    > byte[] buf = new byte[1024];
    > int len = 0;
    > try{
    >
    > while ((len = ClientIn.read(buf)) >= 0)
    > outstream.write(buf,0,len);
    >
    >
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center