0

We have an applet, a jar file that is stored on the desktops and one of the pages of a portal site calls this applet.

We have issues with the applet not initialising in some of the environments and the investigation led to checking the tag where the jar is called.

We are not sure whether we need to use the 'codebase' attribute in the tag. (And we can't just test it easily unfortunately.)

What we have so far in the applet tag is the 'code' attribute that is specified and the 'Archive' attributes which refers to a file on the local machines like this:

Archive='file:///WINDOWS/XYfolder/some.jar'

W3C says that the 'codebase' attribute specifies the base path used to resolve relative URIs specified by the classid, data, and archive attributes. When absent, its default value is the base URI of the current document. (which means it would look for the jar file on the server I guess).

For 'Archive' W3C says, this attribute may be used to specify a space-separated list of URIs for archives containing resources relevant to the object, which may include the resources specified by the classid and data attributes. Preloading archives will generally result in reduced load times for objects. Archives specified as relative URIs should be interpreted relative to the codebase attribute.

- My question is how do you specify a relative URI in the archive attribute and how do you specify an absolute URI?

- Is the Archive attribute specified above as relative or absolute URI?

Many thanks


..how do you specify a relative URI in the archive attribute and how do you specify an absolute URI?

E.G.

Relative

// icon.gif can be found in the docs directory that is a sibling to this directory
"../docs/icon.gif"  
// icon.gif can be found in the docs directory that is a child to this directory
"./docs/icon.gif"

Absolute

// a complete path to a web resource
"http://pscode.org/media/stromlo2.jpg"
// an absolute path to a local resource
"file:///WINDOWS/XYfolder/some.jar"

Is the Archive attribute specified above as relative or absolute URI?

It is an absolute reference.


Note that an applet should not typically be loading Jars off the computer of the end-user (unless they were cached locally by the JRE - but that is all 'invisible' to the app.). That is most likely the real problem here.

4

1 回答 1

1

..如何在存档属性中指定相对 URI 以及如何指定绝对 URI?

例如

相对的

// icon.gif can be found in the docs directory that is a sibling to this directory
"../docs/icon.gif"  
// icon.gif can be found in the docs directory that is a child to this directory
"./docs/icon.gif"

绝对

// a complete path to a web resource
"http://pscode.org/media/stromlo2.jpg"
// an absolute path to a local resource
"file:///WINDOWS/XYfolder/some.jar"

上面指定的 Archive 属性是相对 URI 还是绝对 URI?

这是一个绝对的参考。


请注意,小程序通常不应从最终用户的计算机上加载 Jars(除非 JRE 在本地缓存它们 - 但这对应用程序来说都是“不可见的”。)。这很可能是这里真正的问题。

于 2012-04-05T20:09:48.110 回答