Hi,
I have a servlet which serves an image file which was stored in a blob. If the requested image can't be found, I'd like to server a static image I have included in my war directory. How do we do this? This is how I'm serving the blob images from the datastore:
public class ServletImg extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
{
MyImgWrapper obj = PMF.get().getPersistenceManager().
getObjectById(MyImgWrapper.class, 'xyz');
if (obj != null) {
resp.getOutputStream().write(obj.getBlob().getBytes());
resp.getOutputStream().flush();
}
else {
// Here I'd like to serve an image from my war file.
/war/img/missingphoto.jpg
}
}
}
yeah I'm just not sure how to get the image bytes from the image in my war dir, or if there's some other way to do it?
Thanks