次の単純な埋め込みアプレット html ページがあります。
<html>
<applet code="WelcomeApplet.class" archive="WelcomeApplet.jar" width=300 height=30>
</applet>
</html>
このページ (つまり、アドレスが " http://192.168.0.2/WelcomeApplet.html
") を呼び出すと、アプレットはブラウザに正しく表示されます。
URL ページを表示しないようにするため、このページはサーブレットによってのみ呼び出す必要があります。そのため、doGet
サーブレット メソッドに次のコードが挿入されます。
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());
すべて正常に動作し、解析された HTML は上記と同じですが、アプレットは表示されず、JVM は次のように報告します: " WelcomeApplet.class not found
"
セキュリティの問題ではなく、実装の問題のようです (私は推測します)。
何か案が?
ありがとう