• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JSP File Download

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry folks if this question has already been answered ...but i searched the net quite extensively for this solution but could not find any ...
I have got this jsp page which displays some data in a table (of course dynamically) ... and the same thing is getting written to a csv file at the same time ... i want to have a hyperlink that when clicked on will prompt me to download the same file ...
the best that i have been able to do is that it displays that file in the browser ...
Thanks ...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Buffalo Soldier",
Welcome to the ranch. You may not be aware of the ranch Naming Policy. Please read it carefully and change your name accordingly (obviously fake names are not allowed). Thank you.
 
Buffalo Soldier
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have preferred a more helpful response but n e way i'll try and do that ...
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there's an easy way, it just requires you to create a servlet and have the link point to the servlet. Put your data in session and read it on the servlet, or repeat the logic to generate the data in the servlet, that's up to you.

(from a previous post of mine)
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do so before your next post.
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the location of the .csv file it should be easy to have the link point to the file. Depending upon how the browser is configured to deal with .csv files, it make display it in-browser or prompt the user to download it.

If you need more control over the process, you could write a servlet to stream the file and set the content-disposition header as appropriate.

[Edit: cesar snuck his post in while I was typing. Yeah, that's the idea if a direct link will not suffice.]
 
Buffalo Soldier
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot guys. But I found out another way and (a better-suited one at that for me ). After creating the table I have just placed a button underneath it which will export the table content to an excel file.
I am looking to put just the table in another jsp file so that none other than the table contents will get exported to the excel sheet.
By the way I've got a new problem though ... whenever I am opening the exported table in excel instead of showing data like 1-2 as it is, it is showing things like 2nd Feb or something. Any idea how to get around this? (I think Excel is smarter than we thought or we needed it to be in this case !!!)
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic