繁体   English   中英

通过urlconnection调用html嵌入式小程序

[英]to call html embedded applet by urlconnection

我有以下简单的嵌入小程序 html 页面:

<html>
    <applet code="WelcomeApplet.class" archive="WelcomeApplet.jar" width=300 height=30>
    </applet>
</html>

如果我调用这个页面(即地址是“ http://192.168.0.2/WelcomeApplet.html ”),小程序在浏览器中正确显示。

我应该只通过 servlet 调用此页面,因为不应显示 url 页面,因此在doGet servlet 方法中插入以下代码:

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 WelcomeApplet.class”

看起来不是安全问题,而是实现的东西(我猜)。

任何想法?

谢谢

code属性应命名为 Java class,而不是文件。 (JAR 文件由archive属性命名。)因此,假设它在默认命名空间中, code属性的值应该只是WelcomeApplet

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM