Jacob Kjome wrote:
> I know I can point to files inside a .jar file and display them using
> URL's such as:
> 
> 
>jar:http://www.visi.com/~hoju/assets/resources/resources_test.jar!/images/apache_pb.gif
> 
> and
> 
> jar:file:///C:/resources_test.jar!/images/apache_pb.gif
> 
> 
> However, this is less than useful when one wants to be able to move
> the page and the jar from location to location.  It would entail
> re-editing the html file to change the URL because it has to be fully
> qualified.
> 
> My question is, is there a way to point to a resoruce inside a .jar
> archive in a relative way.  For instance, you can point to an image on
> the file system like this:
> 
> <img src="./assets/images/apache_pb.gif">
> 
> Why can't you do a similar thing with the same resource inside a .jar
> archvie:
> 
> <img
> src="jar:./assets/resources/resources_test.jar!/images/apache_pb.gif">
> 
> 
> Is this at all possible???
> 
> Jake


no, not exactly.  since the relative url you've provided starts with 
"jar:" it will actually be parsed as an absolute url, which will not 
give you what you want.

AFAIK, you can only make the "path within the jar file" relative.  you 
cannot make the "path to the jar file" relative.

if your entire webpage lives in one jar file, then this shouldn't be a 
problem, but if you your toplevel page is not within the jar file, then 
yes, you do have to encode absolute urls, and i can see why that'd be 
inconvenient.  perhaps we could come up with some way to support a 
relative url that would do the job in this case (i.e., using a syntax 
such as or similar to what you suggest).

darin


Reply via email to