I have a servlet that serves an image file that was saved in blob. If the requested image cannot be found, I would like to upload a static image, which I have included in my military directory. How do we do this? This is how I serve blob images from the data store:
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 {
/war/img/missingphoto.jpg
}
}
}
Yes, I'm just not sure how to get the images from the image in my military directory, or if there is some other way to do this?
thank
source
share