I have the following simple embedding applet html page:
<html>
<applet code="WelcomeApplet.class" archive="WelcomeApplet.jar" width=300 height=30>
</applet>
</html>
If I call for this page (ie the address is " http://192.168.0.2/WelcomeApplet.html
"), the applet is correctly shown in the browser.
I should call this page only by a servlet because the url page should not be shown, so in the doGet
servlet method the following code is inserted:
URL url = new URL("http://192.168.0.2/WelcomeApplet.html");
URLConnection conn = url.openConnection();
conn.setRequestProperty("Content-Language", "en-US");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(true);
BufferedInputStream buffer = new BufferedInputStream(conn.getInputStream());
StringBuilder builder = new StringBuilder();
int byteRead;
while ((byteRead = buffer.read()) != -1)
builder.append((char) byteRead);
buffer.close();
out.write(builder.toString());
Everything works fine the html parsed is the same as above, but the applet is not shown, the JVM reports: " WelcomeApplet.class not found
"
It looks like is not a security problem, but an implementation stuff (i guess).
Any idea?
Thanks
The code
attribute should name a Java class, not a file. (The JAR file is named by the archive
attribute.) Thus, the value of the code
attribute should be just WelcomeApplet
, assuming it is in the default namespace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.