• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Downloading an Image from servlet

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have a servlet that does the following in it's doGet method:


I can't change the servlet code. I need a client that will read the image, i have already tried the following:

Although all of the bytes get through, the image created has width and height -1.
Can anybody help ?
Thanks,
Alex.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That means it's not a valid image. If you save the contents to a file, can you then open the file in your default program for PNG images?
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:That means it's not a valid image.


Thanks for the response. That's impossible, because i download the exact same image (using that servlet) onto a j2me application and it shows.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not saying the image on the server is invalid. I'm saying the image on the client is invalid.
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried that. It's funny cause if i use a code i found on the internet to convert Image to BufferedImage, it's working, i can see the image. Thanks, i couldn't do it without your help

But... Once i remove the conversion, i don't see it anymore.

And i can't tell what happens there that makes it show. If i post the conversion method here, you think you can spot why i can see the image only after the conversion ?
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so if i do this:

Image image = Toolkit.getDefaultToolkit().createImage(data, 0, data.length);
Image img = image;

I can see "img" but not "image". Wierd.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic