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. [/b] 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 http://example.com/applet.html can send requests to example.com but it can't send to example2.com due to security limitations.
The java.net.URL 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 java.io.Socket to connect with the server and implement the HTTP request yourself. The request header can be quite simple like: [code] POST /imageuploadhandler.php HTTP/1.1 Encoding: multipart/form-data
[/code]
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.
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.
Comments
[b]Get the server to handle a file upload.
[/b]
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 http://example.com/applet.html can send requests to example.com but it can't send to example2.com due to security limitations.
The java.net.URL 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 java.io.Socket to connect with the server and implement the HTTP request yourself. The request header can be quite simple like:
[code]
POST /imageuploadhandler.php HTTP/1.1
Encoding: multipart/form-data
[/code]
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:
[link=http://www.javaatwork.com/]javaatwork[/link]
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.