• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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: 43081
77
  • 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 ]
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic