• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create the txt file in JSP ?  RSS feed

 
haroic zhou
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to put the data into the txt file
using JSP, Give me a hand, Thank you very much
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37256
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set the content type to text.

If you want the browser to prompt the user to save the file:

Then you can have your JSP or servlet just write out the text.
 
haroic zhou
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jeanne,
But How can we write the text file using jsp?
Would you please give me a good sample?
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to just write to the JspWriter "out", the same way as if you were writing HTML.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37256
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haroic, It's very similar to how you write anything else from a JSP. For example, the following would let you download a one line text file with the current date and time:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!