Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Commonmark migration
Source Link

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also:

See also:

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also:

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

See also:

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also:

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also:

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also:

Source Link
BalusC
  • 1.1m
  • 377
  • 3.7k
  • 3.6k

You're making a conceptual mistake here. In HTML, images are to be represented by <img> element with a src attribute which should point to the image's URL. This is in JSF represented by the <h:graphicImage> component whose value attribute will render the src attribute. It expects a String which in turn represents the image's URL. It does not expect some blob, nor a byte array.

You basically need a servlet here. You should let the image's URL point to that servlet along with the image identifier as request parameter or pathinfo and let the servlet stream the image's content from the DB to the response.

E.g.

<h:dataTable value="#{bean.images}" var="image"> <h:column><h:graphicImage value="images/#{image.id}" /></h:column> </h:dataTable> 

where the #{image.id} returns the unique image identifier. In a servlet which is mapped on an URL pattern of /images/* you can then get it as follows

String imageId = request.getPathInfo().substring(1); 

Finally use this identifier to get the content as InputStream from the DB and write it to the OutputStream of the response along a correct set of headers.

###See also: