Announcement Announcement Module
Collapse
No announcement yet.
Making an image from a URI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making an image from a URI

    Hi guys, probably a very easy question, but google has failed to come up with a decent answer for me

    I need to create an image from a URL in my controller and pump it back out via a servlet outputstream.

    I currently do this

    byte[] pictureBytes = applicant.getProfileImage();
    String pictureExtention = "image/" + applicant.getProfileImageExtention();
    ServletOutputStream servletOutputStream = response.getOutputStream();
    response.setContentType(pictureExtention);
    response.setContentLength(pictureBytes.length);
    servletOutputStream.write(pictureBytes, 0, pictureBytes.length);
    servletOutputStream.flush();
    servletOutputStream.close();

    however if applicant.getProfileImage() == null I would like to reutrn the image located at images/noProfileImage.jpg

    Please help!

    Warm regards,

    Werda
Working...
X