open file

What I am trying to do is, the moment I selected the file ,the image will render and the when the user clicks on the link (see the image is inside a command link) the file selected will open. User can attach any type of file .

mybean :

I am stuck with this. The file is not opening. I can get printed statements only upto contentlength(in the method). Could anyone please help me to find out where am going wrong ?