问题
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
回答1:
..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.
来源:https://stackoverflow.com/questions/10027034/specifying-attributes-in-the-applet-tag