• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to link a text file for download from a JSP page...  RSS feed

 
Sumanth R Prasad
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
without actually displaying it in the window itself....
(since text is a displayable format....the browser opens it directly in the window..)
Is there any way to make the browser ask the user to "whether oen or save" as it does for most other file formats....
If not.... at least is there a way to display the contents of the text file in its original format in a new window...??
Thanx in advance....
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumanth,
Displaying the text file in its original format is very easy, you can use the HTML <pre> tag and within the opening and closing of the pre tags include the text file, e.g:

To open in a new window you can use JavaScript (window.open) to open a new window that simply loads the above JSP file.
As for asking whether to display or download, I am not sure.
HTH
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a search for the term 'disposition' through this and the Servlets forum (and perhaps the HTML forum) to see if setting the content disposition of the response returning the contents of the text file may be a suitable solution for you.
hth,
bear
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!