Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Image Size in bytes

 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends
I have a applet where an image is loaded. Now when a save button is pressed an URL connection is requested and an image is written to the ObjectOutputStream object and request to the servlet call is made.
Now within the servlet i have to get the size of the image from the request input stream. Can anyone help?
The reason to know this is because after I get the image from the request i would like to compress using encoder and save in database. Now I have the size in bytes after compression , But i would like to know the size before compression. Pleaseeeeee guys???
Regards
Farouk
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be a silly question, but if all you have is a single image file, why are you using an ObjectStream? If the file has been fetched from disk it probably came in as a stream of bytes, so why not just send those bytes straight to the server and convert to an object at the server end?

If this decision is out of your hands, can you tell us what Java class your transferred object is? Maybe it already has a method to get its size.
 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your understanding. Offcourse it is not a silly question.
Ok in the applet this is the code I have for creating a request to servlet to save

Hope it is clear

Thanks
Farouk
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic