In other words, Windows is associating JSP file extensions with the wrong software program. We highly recommend scanning your Windows registry for invalid file associations and other related registry issues. Software Downloads Associated with File Extension JSP: FileViewPro* (free trial download) Java Server Page (Sun). The user can download the file by clicking on a hyperlink which points to the servlet URL. This would be useful for implementing file download functionality in your web application using Java servlet. The typical steps are as follows: Read the file on the server using FileInputStream class. Determine MIME type of the file.
- Download File For Adobe Flash Player
- Find Download File
- Jsp Download Pdf File From Server
- Download Zip File From Server In Jsp
I have written a program in Java/JSP which dynamically creates a CSV file based on user input and stores it (on the server).
How can I allow the user to download this file?
Currently using the following to decide the path to store the file.
According to my research, the best bet is to store it in the web-directory and provide the relative path to the file. In that case, where should I store the file (or how should I store it to the web-directory)?
NOTE: The above path is being set in the JSP, and hence I can use the same variables to provide the URL/path to the users
NOTE 2: Server is a tomcat server
PlaymakerPlaymaker2 Answers
You could create a file and -without storing it on the server- return it immediately as a downloadable file to the client.
This has the advantage that you don't need temporary storage on your server that might grow and keep growing unless you regularly clean it out.
Ofcourse if you wish to create an 'archive' of old CSV files as a service to your clients then this is no real advantage. But most of the time the 'create/offer-for-download/throw-away' is the more interesting approach.
Here's some example code that may give you some idea:
1) the servlet (note: exception handling not shown)
2) configuration in WEB-INF/web.xml
3) the link on your page to trigger the download:
Here, /myapp
is the 'context-root' of your application, /download
is configured in web.xml
to be the location that triggers the CsvDownloadServlet
code. p
is an example parameter (see servlet code).If you have a form where the user fills in the parameter values, it could look like this:
This has the same effect as the previous <a>
link, only the parameters are user supplied. As soon as the user clicks the submit button, the servlet code will be invoked and the CSV generation and subsequent download will start.Again, user input checking is not shown.
Download File For Adobe Flash Player
Not the answer you're looking for? Browse other questions tagged javahtmljsp or ask your own question.
Table Of Content
- 1- Database
- 2- Upload and download from database
- 3- Upload and store in DB
- 4- Download from Database
- 1- Database
- 2- Upload and download from database
- 3- Upload and store in DB
- 4- Download from Database
1- Database
2- Upload and download from database
You can use any database, above is a script to create ATTACHMENT table, this table used to store data files that you upload.