I trying to return an image from a servlet as attachment. I know this question has been asked before but I couldn't find an answer on the forum. The code to do this I copied from here: [ UD: removed link to copyrighted material ]
When I run the code I get no error. But when I open the attachmend dialogue I get the error that no file exists. The file is empty. I did some debugging but found no error. The picture has a size of 3k. The picture is in place under the path on the server.
Does anyone have an idea what's wrong?
cheers, Pete [ August 03, 2007: Message edited by: Ulf Dittmer ]
Also, if your file is kept within your web app, you might want to consider using context.getResourceAsStream instead of new File to read the image file. The former will work regardless of how your application is deployed. The getRealPath method will return null if your app is deployed from a packed war file.