Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1022285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:26:34+00:00 2026-05-16T11:26:34+00:00

I have a Java Applet that is generating an image. Ultimately, I would like

  • 0

I have a Java Applet that is generating an image. Ultimately, I would like to insert the image data into a database, so I want to temporarily store the image data in a form field on the page containing the applet. I am hoping to do this without storing an image file on the client machine.

This all comes from a signature pad. Here is some code that is supposed to generate a bit maped image from vector data stored in the sigObj object:

sigObj.setImagePenWidth(10);
sigObj.setImageXSize(1000);
sigObj.setImageYSize(350);
image = sigObj.sigImage();

The image variable is a BufferedImage object. Also, here is the alert output if I just send the image variable back to my JavaScript:

BufferedImage@fe748f: type = 5 
ColorModel: #
pixelBits = 24 
numComponents = 3 
color space = java.awt.color.ICC_ColorSpace@641e9a 
transparency = 1 
has alpha = false 
isAlphaPre = false 
ByteInterleavedRaster: width = 1000 height = 350 #
numDataElements 3 
dataOff[0] = 2

(Line breaks added for readability)

Is it possible to send the image itself back? Any suggestions?

I do not know much Java, so I apologize if I am asking a dumb question.

Thank you.

Edit:

As per the suggestion from BalusC, here is the code I used to convert the image into a Base64 string for anybody who might be curious: (img is a BufferedImage, dataImg is a String)

import org.apache.commons.codec.binary.Base64;

...

try{        
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(img, "BMP", baos);
    byte[] bytes = baos.toByteArray();
    dataImg = new Base64().encodeBase64String(bytes);
} catch(Exception e) {}

This uses the Apache Commons Codec to do the Base64 encoding. Maybe this is trivial, but it was new to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:26:35+00:00Added an answer on May 16, 2026 at 11:26 am

    You have basically 2 options:

    1. Encode it from byte[] to String using Base64 so that the binary data won’t be malformed when being transferred as character data. Then, let JavaScript set it as some hidden input value of some POST form. In the server side, you need to Base64-decode it to get the original byte array back.

    2. Use Java to fire a HTTP POST request programmatically inside the Applet. The Java SE API offers the java.net.URLConnection for this (little tutorial here). A more convenienced API is the Httpclient. In the server side you just need to handle it as a regular POST request parameter.

    It’s unclear what server side programming language you’re using, so I can’t give a more detailed answer for that side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.