Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBOSS CMS opening txt Files

 
Tanvi Narula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

We have application where in user can add files to a form. These files are then uploaded to JBOSS CMS system using jboss cms api's. When user views file they are shown as link of CMS file which begins with /portal/content/default. Now for any image, pdf,.. files the link takes to Open/Save dialog box where user can save the file which is ok, but for text files, the file is opened in JBoss CMS default page.


Instead we want file to be opened in either Notepad or Wordpad or should ask user to save the file on system.

how can we do with JBOSS CMS.



Thanks!!
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem here is with the mime type, and how the browser handles the mime type. When a .txt file is sent to the browser, it simply displays the text. You might have to instruct your users to right-click the link and choose "save link as".

If you are writing your own download code, you can usually set the mime type to a generic object type, in which case the browser always pops up the save dialog. I recall doing something like that once, but it was many years ago. I don't know if there is any way to configure the CMS to do that.
 
Tanvi Narula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter for reply.

The problem with link is "it is a CMS link" and when we do right-click save as , it is saved as HTML page.
I am also trying to send the file from server , where in I set the content-type to be application/x-download and content-disposition as attachement; filename = "somefile.txt"
but its still not working, the file still opens in browser same window.

Do you have any idea why setting content type different than text/plain won't work and does content-disposition work on IE8 and Firefox?

Thanks!!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tanvi Narula wrote:


I am also trying to send the file from server , where in I set the content-type to be application/x-download and content-disposition as attachement; filename = "somefile.txt"
but its still not working, the file still opens in browser same window.


What happens if you set the filename="somefile" and remove the .txt extension? Maybe the browser is being smart when it sees the .txt extension.
 
Tanvi Narula
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does not help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic