java - REST call returns png, how do i render this? -
i testing rest endpoint using restclient, , content-type of response "image/png". how render content type in html? using java , play! controller, have line:
promise<ws.response> imagepromise = ws.url(endpoint).get();
i using plain html/css view. thanks.
you can use data uri scheme (http://en.wikipedia.org/wiki/data_uri_scheme) display image. example, in jsp/servlet code:
<% promise<ws.response> imagepromise = ws.url(endpoint).get(); inputstream imagestream = // image stream string base64image = // read stream, , base 64 encode (you can use apache commons codec library this) %> <img src="data:image/png;base64,<%= base64image %>" />
Comments
Post a Comment