Java Applet 不缓存

发布于 2024-08-30 14:56:02 字数 1224 浏览 4 评论 0原文

我部署的 Java 小程序有问题,该小程序拒绝缓存在 jvm 的“粘性”缓存(或浏览器)中。由于某种原因,每次用户加载该小程序所在的页面时,jvm 都会从服务器重新下载 jar 文件,这会导致长时间延迟。

包含小程序的网页是通过互联网访问的,因此根据 Sun 的 Java applet 文档 我使用的是 标记,而不是 ; 标签。

任何调试或识别问题的帮助将不胜感激。

以下是我正在使用的完整小程序标签:

<applet alt="Scanning Applet failed to load" archive="scanning.jar"
        code="scanning.scanlet.class" codebase="/java/" codetype="application/java"
        height="30" mayscript="True" name="scanlet" width="200">
    <param name="domain" value="192.168.12.23" />
    <param name="publishName" value="scan_attachment" />
    <param name="publishURL" value="http://192.168.12.23/draft/update/52" />
    <param name="curURL" value="http://192.168.12.23/draft/edit/52" />

Your browser is unable to process the Java &lt;APPLET&gt; tag needed to display this applet
<br />
One solution would be to download a better web browser like
<a href="http://www.mozilla.com/firefox">Mozilla's Firefox</a>

</applet>

I'm having a problem with a Java applet I've deployed that is refusing to be cached in the jvm's "sticky" cache (or by the browser). For some reason every time a user loads the page this applet is on, the jvm re-downloads the jar file from the server which causes a long delay.

The webpage containing the applet is being accessed via the internet, so according to Sun's Java applet documentation I'm using an <applet> tag rather than an <object> or <embed> tag.

Any help debugging or identifying the problem would be much appreciated.

Below is the full applet tag I'm using:

<applet alt="Scanning Applet failed to load" archive="scanning.jar"
        code="scanning.scanlet.class" codebase="/java/" codetype="application/java"
        height="30" mayscript="True" name="scanlet" width="200">
    <param name="domain" value="192.168.12.23" />
    <param name="publishName" value="scan_attachment" />
    <param name="publishURL" value="http://192.168.12.23/draft/update/52" />
    <param name="curURL" value="http://192.168.12.23/draft/edit/52" />

Your browser is unable to process the Java <APPLET> tag needed to display this applet
<br />
One solution would be to download a better web browser like
<a href="http://www.mozilla.com/firefox">Mozilla's Firefox</a>

</applet>

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

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

发布评论

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

评论(4

心清如水 2024-09-06 14:56:02

我遇到了同样的问题,并发现了一个需要在服务器端应用的技巧。如果 jar 的 mime 类型不正确,则它们似乎不会被缓存。请使用 application/java-archive mime 类型检查您的服务器回复。

我发现的另一个问题与特定的 jar 有关。我的归档参数列出了许多 jar,但只有少数被缓存。我发现所有罐子直到一个特定的罐子都被缓存,所有剩余的罐子根本没有被缓存。
加载小程序时,我在其 java 控制台中按了“5”,并在最后一个缓存的 jar 之后发现了此消息:cache:jar 中缺少签名条目。我仍然不知道这个文件出了什么问题,但我将该 jar 移到了存档参数列表的末尾。这“解决”了问题。

I had the very same problem and found a trick that need to be applied server side. It seems that jars aren't cached if their mime type is incorrect. Please check your server reply using the application/java-archive mime type.

Another problem I found is related to a specific jar. My archive parameter was listing many jars, but only a few were cached. I found that all jars upto a specific one where cached, all remaining jars weren't cached at all.
While loading applet, I pressed "5" in its java console and found this message just after the last cached jar: cache: signed entry missing from jar . I still don't know what is wrong with this file, but I moved that jar at the end of the archive parameter list. This "fixed" the problem.

还在原地等你 2024-09-06 14:56:02

就个人而言,我通过使用 http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/applet_caching.html

我的cache_version基于实际的文件修改日期,例如

val archive = libs.map("/" + _.getPath).mkString (", ")
val version = libs.map(_.getUpdated / 1000 / 20 - 59281420).mkString (", ")

并且可以工作使用 MSIE 它看起来像:

if (msie) {
  cms write <OBJECT
    classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
    codebase="http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab"
    width="100%" height="100%">
    ...
    <PARAM name="cache_archive" value={archive}/>
    <PARAM name="cache_version" value={version}/>
  </OBJECT>
} else {
  cms write <applet ...
    cache_archive={archive} cache_version={version}></applet>
}

Personally I solved the caching issues by using cache_archive and cache_version parameters docummented at http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/applet_caching.html

My cache_version is based on the actual file modification date, e.g.

val archive = libs.map("/" + _.getPath).mkString (", ")
val version = libs.map(_.getUpdated / 1000 / 20 - 59281420).mkString (", ")

and to work with MSIE it looks as:

if (msie) {
  cms write <OBJECT
    classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
    codebase="http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab"
    width="100%" height="100%">
    ...
    <PARAM name="cache_archive" value={archive}/>
    <PARAM name="cache_version" value={version}/>
  </OBJECT>
} else {
  cms write <applet ...
    cache_archive={archive} cache_version={version}></applet>
}
回眸一遍 2024-09-06 14:56:02

这篇官方文章介绍了如何更改 APPLET 标记以增加缓存:

http ://java.sun.com/products/plugin/1.3/docs/appletcaching.html

This official article describes how you can change your APPLET tag to increase caching:

http://java.sun.com/products/plugin/1.3/docs/appletcaching.html

野の 2024-09-06 14:56:02

对我来说,我必须从 Archive 标签中删除 Jar 文件,然后将其放在 cache_archive 参数中,并指定版本,这样它就不会回载到服务器上的最后修改日期

在 Firefox 中为我修复了它

For me I had to remove the Jar files from the Archive tag and just have it in the cache_archive parameter, and specify the versions that way it doesn't piggy back to the server for last modified date

Fixed it in firefox for me

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