Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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

save result of jsp to text file /word file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a Jsp page, which gets the data from the database, then display it for user to view. and now, how I want to save the result of the page which is seen at the browser to a text/word file.

for example, below is what the user will see from a web browser:
- - - - - - - - - - - - - - - - -
Sno | Code | Name |
- - - - - - - - - - - - - - - - -
a1 | a2 | a3 |
- - - - - - - - - - - - - - - - -
b1 | b2 | b3 |
- - - - - - - - - - - - - - - - -
Now my required output file Should be like this (output.txt)

Sno, Code, Name
a1, a2, a3
b1, b2, b3

Thanks in advance.
keerthi.
 
keerthi malyala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have set the content type like this
response.setContentType("text/html");
and also
response.setHeader("content-disposition","attachment; filename=test.txt");
but the format which i wanted is not coming.the saved file(test.txt)in this case is displaying all the html tags(like <td width="20%" etc) also along with my required data..how can i make it display only the result of jsp data displayed at browser, excluding the html tags? .

Thank you,
keerthi
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want it to display as plain text, why did you use "text/html" instead of "text/plain"?

It is also helpful if you add a Content-Disposition header with a filename that ends in ".txt" because MSIE sometimes ignores content type headers.
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic