Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to download dynamic data in struts

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Experts,

I am working on project in struts and tomcat 6.0 .

I am displaying some data on a jsp and i want that the data i am displaying on the jsp the user should be able to download it as a .txt or .html file. The data is basically a Array list of type String .
This data is coming dynamically from database and changes depending on user selection.

I tried some code from the net but the code returns all my other stuff from jsp like images,javascript etc. Its like looking at my jsp's source code.

I have the the Array List available at my Action Class. And i want that only the contents inside this Array list should only be downloaded .

I am stuck So please guide me through this . I cannot store this file on the server as the content of the file changes on every selection .

Thank you in advance ,

Regards.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to download that text, then on 'Download' link action, perform following steps:
1. Create a temp file
2. Write all the string into that file.
3. By setting proper header, forward


If you want the user can copy paste the generated text, then use:
<textarea cols="12" rows="3"><jsp:include page="GetTheText.do"/></textarea>
GetTheText is mapped to the action and opens the "out" stream and write the strings, like

PS: I never tried both the example before, so let me know Ranchers whether my appraoch is correct or not
 
Anjali Pal
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1. Create a temp file
2. Write all the string into that file.



Am just confused about where this temp file should be stored to avoid any problems at the time of deployment.

Right now during development i can store it any where but which is the right and best place to store or create the temp file, to avoid deployment time troubles.



And i tried this code but as i said it returns the entire jsp and not the specific section of it .

Thank you ,

Regards.



 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anjali Pal wrote:

1. Create a temp file
2. Write all the string into that file.

Am just confused about where this temp file should be stored to avoid any problems at the time of deployment.
Right now during development i can store it any where but which is the right and best place to store or create the temp file, to avoid deployment time troubles.


Do not worry about the temp file creation, it is handled by Java. For more info on creating temp file, Google temp file using Java. You can also create your own dir into the web app named "temp".

Anjali Pal wrote:

And i tried this code but as i said it returns the entire jsp and not the specific section of it .


Entire JSP ?? Have you tried specifying the filename in the header ?
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic