Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 23, 2012, 04:47:59 PM

Pages: [1]   Go Down
  Print  
Author Topic: Images from database not being displayed.  (Read 678 times)
mstacey01
Newbie
*
Offline Offline

Posts: 1


« on: January 02, 2009, 10:37:45 AM »

I have some images in a mysql database stored as blobs that I am attempting to display. It works fine when I work on my local environment using tomcat and netbeans, but when I upload my war to lunarpages, the images are not being displayed. I've pointed my local ide to the lunarpages database and I still get the images displayed, so it's not the database. Here is my code:

In the jsp I want it displayed in I give the following.

<a href="javascript:doDetails('<%=((Product)element).getProductId()%>')">
     <img src="filedisplay.jsp?fileId=<%=fileId%>" height="64px" width="64px"></br>
</a>

In filedisplay.jsp I have

String fileId = request.getParameter("fileId");
Service service = new Service();
FileImage f = null;
f = service.getFile(Integer.parseInt(fileId));
   
if (f != null) {
    response.setContentType(f.getContentType());
    OutputStream bout = response.getOutputStream();
    try {
        bout.write(f.getSmallBlob());
    } finally {
        if (bout != null)
            try { bout.close(); } catch (Exception e) { System.err.println("unable to close OutputStream: " + e.getMessage()); }
    }
} else {
    out.write(("<html><head><title>File Not Found</title></head><body><br>"));
    out.write(("<div class='frm_error'><p align='left'>The File [" + fileId + "] does not exist. Contact your frontline support.</p></div>"));
    out.write(("</body></html>"));       
}

Any help would be greatly appreciated.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: