Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Applets use Browser for HTTP Requests?

Is there any interaction between applets and their hosting browser when making HTTP requests, or are requests made completely independently of native browser code?

Specifically, do Java applets running in a browser have some implicit way of sharing the browser's session state and cache?

I've read a few posts from non-authoritative sources saying that when an applet makes an HTTP request that it will use the browser's cache, and that it will also have access (somehow) to the browser's cookies.

Tests I've done using URLConnection suggest that this is not the case, and my gut feeling is that it sounds far too convenient to be true. I would assume that nothing in the JVM knows anything about the world outside of that JVM, meaning the only other way this could work would be if the JVM implementation is specific to the browser its implementation of the URL-related methods delegate to native browser code?

If cookie data is not implicitly shared or available, is best practice to pass a session ID in a param tag to the applet? Are there security concerns with this approach? If the applet doesn't use the browser's cache for requests, how does caching requests in an applet work?

like image 737
EngineerBetter_DJ Avatar asked Jun 20 '12 07:06

EngineerBetter_DJ


People also ask

Can Java applets run from a Web browser?

Applets are run inside a web browser via the web browser's "Java Plug-in". This "Java Plug-in" provides a "Java Console", for managing the Java Plug-in and the applets.

Do browsers support applets?

Browsers come with a Java plugin that allows the execution of an Applet on it. And so, the browsers that come to Java enabled, can run Applet without any hassle.

Is a programming language that allows applets to run within a Web browser?

Java applets can run in a Web browser using a Java Virtual Machine (JVM), or in Oracle's AppletViewer, a stand alone tool to test applets. Java applets were introduced in the first version of the Java language in 1995.

What is required to run an applet?

There are two standard ways in which you can run an applet : Executing the applet within a Java-compatible web browser. Using an applet viewer, such as the standard tool, applet-viewer. An applet viewer executes your applet in a window.


1 Answers

Applets are executed by the Java Plugin, which is a browser plugin. The applet is indeed part of an HTML page loaded by the browser, can communicate with the browser DOM and with JavaScript code in the page, and uses the browser to send requests to its originating server.

See http://docs.oracle.com/javase/tutorial/deployment/applet/appletExecutionEnv.html and http://docs.oracle.com/javase/tutorial/deployment/applet/server.html for more information.

like image 160
JB Nizet Avatar answered Oct 10 '22 20:10

JB Nizet