Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to download doc file in jsp in weblogic  RSS feed

 
saleem javeed
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<html>Hi,

I am facing one strange problem, i have written one jsp to download the msword file and it execute fine in tomcat. Same jsp if i try to execute it is opening with junk data.

the code is :


File filepath = new File(nameoffile);
String actualname = filepath.getName();
System.out.println("the actual name in jsp is"+actualname);

String filename = "D://weblogiclive/rtms/resume\\"+actualname;
System.out.println("the filename in jsp is"+filename);



//String filename = "/apps/resume/"+actualname;
//String filename = "erpa/apps/resume/"+actualname;
//String filename = request.getParameter("resumepath");

response.setContentType("application/msword");

response.setHeader("Content-Disposition","attachement;");
File fileto = new File(filename);

FileInputStream fin = new FileInputStream(fileto);

ServletOutputStream outs = response.getOutputStream();

int i;
while((i = fin.read()) != -1)
{
outs.write(i);
}
fin.close();
outs.flush();
outs.close();




please, can any one help me to resolve this.


thanks in advance

saleem
</html>
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use simple forward to proper doc file. I've tried this technique
when sending zip file (which is not accessible directly).
Besides using forward you don't need to worry about buffering and byte to byte sending
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!