• 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

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic