Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Jersey example from documentation is clear enough to me. However, here is a simplified example without parameters (do simple to begin...)</p> <pre><code>@GET @Path("/images/pet") @Produces("image/*") public Response getImage() { File f = new File("C:\\\\Temp\\dog.jpg"); if (!f.exists()) { throw new WebApplicationException(404); } String mt = new MimetypesFileTypeMap().getContentType(f); return Response.ok(f, mt).build(); } </code></pre> <p>As my Jersey is configured as <code>/rest/*</code> path in the <em>web.xml</em> of the <em>yourapp</em> application, the image is accessible at the following address: </p> <p><code>http://serverip:port/yourapp/rest/images/pet</code></p> <p>You can try it directly this URL in the browser navigation bar (it is a REST image service, served as if it was a static image), or if you want it in a html page, you can use classic HTML: </p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;h1&gt;Woof!&lt;/h1&gt; &lt;img src="http://localhost:8080/myapp/rest/images/pet" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Hope it helps.</p> <p><strong>EDIT</strong></p> <p>Okay that was too obvious. So you need to implement a method or service that gives the content of a directory with image file names in the given order you need (as a java List).</p> <p>Using this List, you can build a html like this within a loop:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;h1&gt;Several images&lt;/h1&gt; &lt;img src="/yourapp/rest/images/last.jpg" /&gt;&lt;br/&gt; &lt;img src="/yourapp/rest/images/third.jpg" /&gt;&lt;br/&gt; &lt;img src="/yourapp/rest/images/second.jpg" /&gt;&lt;br/&gt; &lt;img src="/yourapp/rest/images/first.jpg" /&gt;&lt;br/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the result HTML you must output (in JSP or whatever you use). The REST service getImage() will be called automatically by the browser, once for each image.</p> <p>Am I clear ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload