• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Applet Servlet Serialized Object

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an applet that invokes a Twain Device on a Client Machine, the aim of my code is to take photgraphs using a webcam and allow a user to store the image in my database. I have successfully written the applet to handle this and even save the file on the user machine. But I need the Applet to save the image on a DB my server. Can Anyone direct me on how to send a serialised object back to a servlet from my applet.

I would like to send the Image as an output stream to my servlet
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I would like to send the Image..


I don't think there is a Serializable Image class, go for a int[] of pixels maybe. Image objects are all tied up in the graphics capability of a given platform so I don't think they can be serialized.
Bill
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your applet has access to the client file system, which from the sound of it, it does, why not just send it as a serialized instance of java.io.File?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can Anyone direct me on how to send a serialised object back to a servlet from my applet.



Chapter 17 covers this:
http://pdf.coreservlets.com/
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why not just send it as a serialized instance of java.io.File?


How is an instance of File going to help get the image to the server?

Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never tried with an image but I have, in the past, sent serialized Java objects to the server from an applet via HTTP posts by setting the content type to: "application/x-java-serialized-object".

Since java.io.File implements java.io.Serializable, I would think you could send an image (or any file) that way.


Ola,
The first link I posted only covers sending serialized objects from a servlet to an applet. This one has examples of sending serialized objects in both directions.
http://www-128.ibm.com/developerworks/java/library/j-tunnel/?dwzone=java
[ November 22, 2005: Message edited by: Ben Souther ]
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
File objects can be serialized, but they represent just the file descriptor, not the contents. They only have meaning on the originating machine; you can't send them over the wire.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.
So the file would need to be read and the stream sent to the server.

My mistake.
Thanks William, Ulf.
[ November 22, 2005: Message edited by: Ben Souther ]
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben Thanks for all the help. Problem solved. I convert the image to a bytes array in the applet and send it back to my servlet, which then inserts it in the database.

Both links were very verrryy halpful. Thanks Again
[ November 23, 2005: Message edited by: Ola Daniel ]
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic