Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

downloading file  RSS feed

 
Sonalee Mohapatra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
was asked this question recently :
you are downloading a file (by clicking on a button/link) on a jsp. since its a big file and will take time to download, you need to show the size of the file and download status to the user. how will you do it ?
any answers appreciated
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sonalee Mohapatra:
was asked this question recently :
you are downloading a file (by clicking on a button/link) on a jsp. since its a big file and will take time to download, you need to show the size of the file and download status to the user. how will you do it ?
any answers appreciated

I don't think I really understood your question. jsp is executed on the server side. You don't have control on user's system. Anyway browser/download manager will show the progress.
If it's an upload script, you can show the progress.Do you want to upload or download?
Can you rephrase your question?
 
Sonalee Mohapatra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm, ok, i think i got the question wrong. its an upload, not a download. please let me know how to do it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66143
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Sonalee, welcome to the Ranch!
You'll find these forums full of helpful, friendly people who are willing to spend time and effort to help you with your questions. What you will not find is people who have the time or inclination to do your homework, assignments or other coding for you. You need to make the effort to try your hand at any problem you might have. Then you can post what you've tried and expect mounds of help on the aspects that are causing you pain and aggravation.
So, what have you tried and what portion of it is giving you angst?
bear
JSP Bartender
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66143
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Have you searched this forum for answers? This very subject has been discussed on numerous occasions.
hth,
bear
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the user clicks the "Upload" button, the client browser locates the local file and sends it using HTTP POST, encoded using the MIME-type multipart/form-data. When it reaches your servlet, your servlet must process the POST data in order to extract the encoded file. You can learn all about this format in RFC 1867.
Unfortunately, there is no method in the Servlet API to do this. Fortunately, there are a number of libraries available that do. Some of these assume that you will be writing the file to disk; others return the data as an InputStream.
Some resources
http://www.servlets.com/resources/com.oreilly.servlet/index.html
Jason Hunter's MultipartRequest
http://jakarta.apache.org/commons/fileupload/ :Apache Jakarta Commons Upload (package org.apache.commons.upload) "makes it easy to add robust, high-performance, file upload capability to your servlets and web applications"
http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html :
UploadBean by JavaZoom claims to handle most of the hassle of uploading for you, including writing to disk or memory
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you have the stream object referring to the file to be uploaded(which the above beans will give) showing progress of file is very easy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!