Hello I'm building a servlet to display an image - nothing new here. The problem I'm facing is that the image is being forced to download in the browser instead of being displayed on the page. I've tested in Chrome/Firefox and IE. When the image is downloaded the file size is correct, but the file is downloaded with the filename the same as the requesting page (getimage). And the type application/octetstream. I do set the content type in the getImage servlet.
The code steps: 0. Call the getimage servlet from jsp 1. retrieve the image info - blob and content type. The query uses the current user to fetch the image from the datastore so on url params are needed in this case. 2. Explicitly set the content type of the response 3. Write the blob as bytes into the output stream The code: #0. profile.jsp <img src="/getimage"> #1-3 #Servlet_GetImage.java public class Servlet_GetImage extends HttpServlet { private static final Logger log = Logger.getLogger(Servlet_GetImage.class.getName()); public void doGet(HttpServletRequest req, HttpServletResponse resp){ UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if(req.getParameter("imageId")==null&&user!=null){//we will fetch the profile image - no imageId params are needed & the user must be logged on DS_ProfileImage myImage = (DS_ProfileImage)ProfileImage.fetchImage(user); if(myImage!=null){ try{ resp.setCharacterEncoding(myImage.getContentType()); resp.getOutputStream().write(myImage.getBlob().getBytes()); } catch(Exception e){ log.warning("ERROR: "+e.getMessage()); } } } else{ //TODO: create a fetch image method for images other than Profile images } } } -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.