Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

save result of jsp to text file /word file

 
keerthi malyala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic