This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to download file from jsp page

 
Nilesh Chokhadia
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I want to download a file from JSP page the downloaded file is already in my application.
URL for same file is given like
response.sendRedirect("a.jsp?mFileName="+mFileName+"&mUser="+mUser+"&mpath="+directoryName);
what code I have to wrie down in a.jsp file
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll write some codes that are important and neccessary to sending the binary file to the users, ok? And u have to handle the path and directory location by yourself...
response.setContentType("application/jar");
File f = new File(request.getParameter("mFileName")+request.getParameter("directoryName"));
byte[] byteArray = new byte[(int)f.length()];
FileInputStream is = new FileInputStream(f);
is.read(byteArray);
OutputStream os = response.getOutputStream();
os.write(byteArray);
os.flush();
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic