Re: Displaying HTML page with images from ZIP?

Discussion in 'Java' started by Cruithne3753, Feb 10, 2008.

  1. Cruithne3753

    Cruithne3753 Guest

    Andrew Thompson wrote:

    >It is relatively easy to do. Simply ensure that
    >all resource in the HTML are referenced with
    >relative paths, then include the resources in the
    >same ZIP file. If JEditorPane can find the HTML,
    >it should be able to find stylesheets and images
    >etc.


    Is there some sort of URL syntax to reference files within a ZIP?

    Other approach I thought of was to load the HTML via an InputStream,
    search it for the file names, load them the same way and then plug them
    into the document model, but all the documenation I can find only seems
    to refer to the tags in the HTML text rather than the internal
    references the binary representations.

    >
    >> Any ideas?

    >
    >Post an (short) example HTML that is failing,
    >a description or listing of the ZIP content
    >that shows the HTML and the resource, and an
    >SSCCE* (should take no more than 20 lines of
    >code).


    >Actually, I doubt the problem here is code,
    >so the last might not be needed.


    Yep, it's not a case of "why isn't my code working", just can't see how
    to do it... for the time being, I'm extracting the files to a temp
    directory and viewing them from there, it works but just seems a bit grubby.
    Cruithne3753, Feb 10, 2008
    #1
    1. Advertising

  2. On Feb 11, 3:42 am, Cruithne3753
    <> wrote:
    > Andrew Thompson wrote:
    >
    >  >It is relatively easy to do.  Simply ensure that
    >  >all resource in the HTML are referenced with
    >  >relative paths, then include the resources in the
    >  >same ZIP file.  If JEditorPane can find the HTML,
    >  >it should be able to find stylesheets and images
    >  >etc.
    >
    > Is there some sort of URL syntax to reference files within a ZIP?


    Sure there is. It involves an '!' after the
    jar name, followed by the path within the Zip.
    Best way to check is to use class.getResource()
    for something on the app's classpath, then print
    the URL.

    --
    Andrew T.
    PhySci.org
    Andrew Thompson, Feb 11, 2008
    #2
    1. Advertising

  3. Cruithne3753

    Roedy Green Guest

    On Sun, 10 Feb 2008 17:42:45 GMT, Cruithne3753
    <> wrote, quoted or
    indirectly quoted someone who said :

    >Is there some sort of URL syntax to reference files within a ZIP?


    yes, but it is easier to use getResource to generate the URL.

    I explain this at http://mindprod.com/jgloss/image.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Feb 11, 2008
    #3
  4. Cruithne3753

    Cruithne3753 Guest

    Roedy Green wrote:
    > On Sun, 10 Feb 2008 17:42:45 GMT, Cruithne3753
    > <> wrote, quoted or
    > indirectly quoted someone who said :
    >
    >> Is there some sort of URL syntax to reference files within a ZIP?

    >
    > yes, but it is easier to use getResource to generate the URL.
    >
    > I explain this at http://mindprod.com/jgloss/image.html
    > --
    >
    > Roedy Green Canadian Mind Products
    > The Java Glossary
    > http://mindprod.com


    That works splendid, thanks!
    Cruithne3753, Feb 12, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    1
    Views:
    596
    Andrew Thompson
    Sep 16, 2004
  2. Replies:
    0
    Views:
    1,717
  3. HARI OM
    Replies:
    0
    Views:
    17,408
    HARI OM
    May 3, 2005
  4. sunil_varma
    Replies:
    1
    Views:
    1,170
  5. Cruithne3753
    Replies:
    3
    Views:
    434
    Roedy Green
    Feb 11, 2008
Loading...

Share This Page