Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

not able to load images  RSS feed

 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i've made an application(through sockets) which runs in between the browser and server. The application captures the incomming request from the browser and sends it tothe server. Before sending the request tothe server it creates a URL object and extracts the content of the URL (the clients requests)and sends it back to the browser.In doing so it only displays the html bit not the images . please help.
thanks in advance
 
Pravin Bhalerao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I'm also writting same type of application with only sockets.do u get the distorted images?
I guess ur using character reader/writter to read the data from proxy or to write to the browser.
try with buffered IOStream...
Pravin Bhalerao
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Yes . i get distorted images when i use an inputstream and read the data byte by byte . When i use DataInputStream and read the data line by line in a string,i don't get any images . i've even tried it with BufferInputStream but in vain.
The second problem i,am facing is that whenever i access any site which requires dataBase connectivity ( like yahoo ) my application doesn't work there . As i told earlier that i,am trying to extract content from a URL with the help of the URL class. Now when i have login on some site it fails to verify my login .Please help as soon as posible .
Thanks in advance

Thanks in advance
Originally posted by Pravin Bhalerao:
hi,
I'm also writting same type of application with only sockets.do u get the distorted images?
I guess ur using character reader/writter to read the data from proxy or to write to the browser.
try with buffered IOStream...
Pravin Bhalerao

[ September 12, 2002: Message edited by: raghav mathur ]
 
Pravin Bhalerao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have used BufferedInputStream, it works fine with images. It b'se of conversion of bytes to char when using character streams.here is the code snipet i'm using,
int bytesRead;
BufferedOutputStream browserWriter = new BufferedOutputStream(browserOutputStream);
BufferedInputStream proxyReader = new BufferedInputStream(proxyInputStream);
{
System.out.print((char)bytesRead);
browserWriter.write(bytesRead);
browserWriter.flush();
System.out.flush();
}
abt. the second problem - login to yahoo,
i'm also getting the same problem. I think it's because of cookies, whenever u loggs in to yahoo it starts the session using cookies. some handshaking takes place between browser and the server which we may not be handling.
i have posted the same query few days back but didn't get any reply.. if u got any , let me know..
Pravin Bhalerao
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin
Now this is a function which captures whatever you write in the address bar of the brower and constucts a URL object , extracts the content and displays it on the browser.
I've used BufferedInputStream to extract the contents and read them .
Are you also constructing a URL object for establishing a connection ?
As far as the login prob is concerned i think the parameters which are passed through
the text fields are not reaching the desired target that is why whenever you login on any sitefor that matter it will display the login page again and again. I,am working on that too and will definately let you know. In the meanwhile have a look at the code .

Thanks in advance
 
Pravin Bhalerao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i've not used URLConnection. i opens connection with the proxy server using sockets. it works fine. In URLConnection for gifs did u set the content-type in header?
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then how are you retrieving the contents. As far as setting up the content type is concerned i,am bot doing that but still getting distorted images .How is that possible . How do i set the content-type anyways?
Thanks in advance
Originally posted by Pravin Bhalerao:
hi,
i've not used URLConnection. i opens connection with the proxy server using sockets. it works fine. In URLConnection for gifs did u set the content-type in header?
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh My God !
I don't believe this!
I was reading the data through a bufferstream but forgot to write the data with the same.I was using writers . The images are now loading perfectly(after using bufreredInput and output). Can you please explain why is BufferedInput and output streams are necessary in this kind of a scenario.
Thanks in advance
[ September 17, 2002: Message edited by: raghav mathur ]
[ September 17, 2002: Message edited by: raghav mathur ]
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading the images byte by byte takes a lot of time for the images to get loaded on to the browser. How can improve this ?
Thanks in advance
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!