aspose file tools*
The moose likes JSP and the fly likes download help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "download help" Watch "download help" New topic
Author

download help

Suka Hati
Ranch Hand

Joined: Oct 28, 2004
Posts: 56
hi!!! i have a jsp page where in that page i made a hyperlink. if the user click the hyperlink, they will get a pop-up a windows ask whether user want to open or save the file. the file actually stored in server. all the idea behind this is to give the user the ability to open or save a file that been stored in server.do anybody have an idea on this
[ December 01, 2004: Message edited by: Bear Bibeault ]
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Originally posted by Suka Hati:
hi!!! i have a jsp page where in that page i made a hyperlink. if the user click the hyperlink, they will get a pop-up a windows ask whether user want to open or save the file. the file actually stored in server. all the idea behind this is to give the user the ability to open or save a file that been stored in server.do anybody have an idea on this


hey, this will happen when you have associated exstention configured in window (not sure abt the unix) , say if u dont have the download file format u need to add this file format in windows


so then it automatically ask to open or save the file with known extention

try to download the .txt file and see the result

then try to download .java file then see the result.

will help you .....

Suka Hati
Ranch Hand

Joined: Oct 28, 2004
Posts: 56
i try to use below code but when it generate the downloaded file...the file corrupted....i dont know what couse this error



<%@ page language="java" import="java.io.*"%>
<%
String filePath;
//
//String filePath="C:\\Program Files\\Apache Group\\jakarta-tomcat-4.1.29\\bin\\temp.wav";
String fileNameNew="temp.wav";
filePath="/bin/"+fileNameNew;
response.setContentType("audio/wav");

response.addHeader("Content-Disposition", "attachment; filename="+fileNameNew);
try{
File uFile= new File("C:/Program Files/Apache Group/jakarta-tomcat-4.1.29/bin/temp.wav");
int fSize=(int)uFile.length();
FileInputStream fis = new FileInputStream(uFile);
PrintWriter pw = response.getWriter();
int c=-1;
// Loop to read and write bytes.
//pw.print("Test");

while ((c = fis.read()) != -1){
pw.print((char)c);
}
// Close output and input resources.
fis.close();
pw.flush();
pw=null;
}catch(Exception e){
}
%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: download help