This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes save result of jsp to text file /word file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "save result of jsp to text file /word file " Watch "save result of jsp to text file /word file " New topic
Author

save result of jsp to text file /word file

keerthi malyala
Greenhorn

Joined: Jul 14, 2006
Posts: 5
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

Joined: Jul 14, 2006
Posts: 5
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
Don't get me started about those stupid light bulbs.
 
subject: save result of jsp to text file /word file