This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am uploading a file into database which I don't know the extension. While retrieving from database, what content type should I mention in my jsp to provide download feature from database. I can get source code for it.
while uploading store the contenttype and filename in some columns in database. if your filename doesnt contain extn then while download you will see "file unknown type" in download window.
below are the steps for download
1)set contentlength in response response.setContentLength(sizeoffile); 2)set the content type and header response.setContentType(mimetypeofile); response.setHeader("Content-disposition", "attachment; filename=" + filename); 3)get a outputstream from HttpServletResponse and then write the binary data into it. ServletOutputStream os = response.getOutputStream(); os.write(filecontent); 4)return null from execute() method.