wood burning stoves 2.0*
The moose likes Applets and the fly likes How applet talk to another applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "How applet talk to another applet " Watch "How applet talk to another applet " New topic
Author

How applet talk to another applet

Pira Tomatsu
Greenhorn

Joined: Sep 01, 2009
Posts: 14
I got a requirement to build a web application to upload pictures.

A signed JFileChooser to used to select pictures at Client-Side.
After pictures are selected, paths of all pictures have to send to another viewer applet to display(each picture for each applet).
This viewer applet is written by others and it only receives a path of a picture to display through <param> tag.

The question is how JFileChooser applet can send paths of all pictures to the viewer applet.

Sorry for my bad english, hope you can understand. Thank you for your answer.
Pira Tomatsu
Greenhorn

Joined: Sep 01, 2009
Posts: 14
I have more questions. How I can upload multiple files (selected pictures) to a server.

Right now I have no ideas about uploading multiple files. I only know how to write a file at a time.
I use FileIn/OutStream to write to a shared folder which share data with a server instead.
Is it ok to do this?

Thank you again
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Welcome to JavaRanch.

First off, be aware that using a shared folder limits the use of the applet to everybody who can access that folder - say, everybody on the same company network. Nobody outside the firewall will be able to use it. Just something to keep in mind.

Something else to keep in mind is how to organize the files in the shared directory: How do they get unique names? How do you make sure that files uploaded by different users don't have the same names and so overwrite each other? How can a user go back to view all the files she has uploaded? How does the code know which user has uploaded which file?

JFileChooser can only select a single file. If you want to upload multiple files you'll have to invoke it multiple times and upload each selected file individually.

As to transferring control to a different applet, the upload applet needs to remember all names/paths of the files. Then it can either use the AppletContext's showDocument method to switch control to a different page that contains the viewer applet (and pass all file names in the URL), or it can first save the file names to the server (by doing an HTTP POST to a servlet or similar), and then call showDocument to a server URL that knows about the previously POSTed file names, and which can then create the page with the viewer applet and add all the filenames as <param> tags to the <applet> tag.

The former approach (passing filenames in the URL) limits you to just a few files, since URL are generally restricted to 2000 characters or so.


Ping & DNS - updated with new look and Ping home screen widget
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How applet talk to another applet
 
Similar Threads
pictures in a jsp
Query
Query
How can I found paths to "My Computer", "Desktop", ... folders for the current user?
wrting multiple JPEG files to a Servlet output stream