What will be the better approach for sending data from an Applet to a JSP page for processing, using "appletContext and showDocument()" or "setting up an URL Connection and passing data through a stream"?

Serge Knystautas

This depends on what your applet is trying to accomplish. Calling showDocument() could affect the frame the applet is running under, which would shutdown the applet, and even if the same applet was created on the resulting HTML page, this would restart the applet.

If your applet is only a form and is expected to shutdown, then showDocument might work. If you are targeting results to alternate frames in the browser window, showDocument(url, frame) could also be useful. Note that any data passed via a showDocument call necessarily would be sending data only through a query string.

For most applets however, open a URLConnection will give the user more flexibility in terms of the amount of data they can send, and the contents of the post (using URLConnection, you can send data as a POST).

Another more devious way to pass data is to use showDocument to call javascript code by doing showDocument("javascript:myfunction(varx)"); The javascript could then store data as cookies, retrieve the browser's email address, redirect to another page, animate some DHTML, whatever you want. However, this is advanced use and care should be used when attempting this approach.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.