Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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 ?
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic