如何从动态服务器端 URL 加载 Java 小程序?

发布于 2024-08-17 15:26:08 字数 187 浏览 4 评论 0原文

我想从服务器端脚本加载小程序,例如。 Perl CGI 程序等。这可以完成吗?如何?

<applet code=A21 width=256 height=256 archive="http://url/cgi-bin/test.cgi?R=applet">

预先感谢您的所有帮助。

I want to load an applet from a server side script, eg. a Perl CGI program, etc. Can this be done? how?

<applet code=A21 width=256 height=256 archive="http://url/cgi-bin/test.cgi?R=applet">

thanks in advance for all help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒与心事 2024-08-24 15:26:08

我已经很长时间没有这样做了(所以安全模型可能已经改变了),但诀窍是配置服务器来处理一些翻译。假设您有 URL:

 http://example.com/applets/MyCode/1.0

您设置了 URL 转换,以便使用 CGI 脚本处理 http://example.com/applets,然后获取 /MyCode/1.0 em> 作为PATH_INFO。你需要归还什么就归还什么。

你为什么要这样做?

I haven't done this is a long time (so the security model might have changed on me), but the trick was to configure the server to handle some translation. Say that you have the URL:

 http://example.com/applets/MyCode/1.0

You set up the URL translation such that you handle http://example.com/applets with your CGI script, which then gets /MyCode/1.0 as PATH_INFO. You return whatever you need to return.

Why do you want to do this?

歌入人心 2024-08-24 15:26:08

我能够实现这一点。我使用的机制是将 cgi 脚本文件包装在 shell 脚本中。这个包装器调用 cgi 脚本,然后它将带有特殊请求的原始 URL 嵌入到它作为小程序的页面中。然后该脚本将再次运行并检测此特殊请求。它会在没有任何输出的情况下中断,但会返回一个 shellscript 捕获并输出 jar/classfile 的值。

Fetch.sh

run_the_cgi_script.cgi

案例 $?在

0) #normal script operation without special requests
   #do nothing more
;; 

1) #a special request that maps to Test3.class
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/Test3.class;;

2) #a special request that maps to someclass.class
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/someclass.class;;

3) #a special request that maps to somejar.jar
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/somejar.jar;;

esac

I was able achived this. The mechanism I used was that the cgi script file was wrapped in a shell script. This wrapper calls the cgi script and it would then then embed the original url with a special request in the page it served as the applet. The script would then get run again and detect this special request. It would break without any output but with a return value that the shellscript would catch and output the jar/classfile.

Fetch.sh

run_the_cgi_script.cgi

case $? in

0) #normal script operation without special requests
   #do nothing more
;; 

1) #a special request that maps to Test3.class
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/Test3.class;;

2) #a special request that maps to someclass.class
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/someclass.class;;

3) #a special request that maps to somejar.jar
echo "Content-type: application/java-archive"
echo ""
cat ./$myDIR/somejar.jar;;

esac

以歌曲疗慰 2024-08-24 15:26:08

来自文档

出于安全原因,该小程序的
类加载器只能从
小程序的代码库相同
开始了。这意味着档案
在 archiveList 中必须在同一个
目录为,或在其子目录中,
代码库

,所以我怀疑这会有问题。

From the doc:

For security reasons, the applet's
class loader can read only from the
same codebase from which the applet
was started. This means that archives
in archiveList must be in the same
directory as, or in a subdirectory of,
the codebase

so I suspect this will be problematic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文