send information from applet to server


I want to write an applet for painting and I want to send the
result-picture to the server where the applet-code is stored.
But I have no idea how to do that. Does anyone know's an example
or can give me a hint.



  • I have an idea that I'm confident would work but it is a bit complicated. I'll explain the idea here:

    [b]Get the server to handle a file upload.
    Set up a server side script on the server. How you do this will depend on the server supporting server-side technology like PHP or something else. If you are familiar with handling a file upload using PHP, that is basically all you'd need.

    [b]Get the applet to send the image data as a file upload[/b]

    Any applet can send HTTP requests to the server as long as it is the same domain that the applet is in. For example, the applet at can send requests to but it can't send to due to security limitations.

    The class can be used for sending GET-method requests but for simulating a file upload, you'll have to use POST. To do that, you can use to connect with the server and implement the HTTP request yourself. The request header can be quite simple like:
    POST /imageuploadhandler.php HTTP/1.1
    Encoding: multipart/form-data


    The body of the request would have to be encoded in a special format using parameters handled by your imageuploadhandler script. I made a web server a while ago with file upload support but can't remember all the formatting rules for multipart/form-data. I remember each parameter being split into multiple properties. The file contents is given with a marker at the beginning and marker at the end. The file size, file name are all separated. If you are serious about this, I suggest using Wireshark to take a look at messages from regular web browser file uploads so you can see how to replicate them.

    This might be a similar implementation of a similar idea that could avoid the complicated steps above:

  • Crucial to solving your problem is starting out with the ability to write server side scripts that can get work down on the back end. If you don't have these skills, I doubt there exists any solution to your problem.

    Another idea that is simpler than the file upload is to represent the image as vector data. If you collect the data on the server in a database, you could use small requests to just update the server on actions performed by the user. By keeping the messages small, you can pack the information into parameters of a GET request.

    When you need to rasterize the image, you could use some server side image drawing routines like PHP's GD and image functions.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion