Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes your suggested solution will work. Given that you are working in a Java environment storing the images in the database is the best way to go. If you are running in a single server environment with an application server that will let you deploy in an exploded format technically you could store the images on disk but that wouldn't be the best practice. One suggestion would be to use a servlet instead of a JSP. To get good browser behavior you want the browser to think that the file type that it is displaying matches the file type that it is expecting. Despite the existence of mime type headers the file extension is still really important. So you want a link that looks like this:</p> <pre><code>&lt;a href="foo.jsp"&gt;&lt;img src="imageservlet/123456789.png"&gt;&lt;/a&gt; </code></pre> <p>Where 123456789 is the primary key of your image in the database. Your servlet mapping would look like this:</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;ImageServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;com.example.ImageServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;ImageServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/imageservlet/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>Then in your servlet simply parse the request URL for the image ID rather than using the query string as the query string will confuse some browsers. Using the query string won't break browsers outright but you'll get odd behavior with regards to caching and some browsers may report the content as unsafe.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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