Meaningless Drivel is fun!*
The moose likes JBoss/WildFly and the fly likes JBOSS CMS opening txt Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBOSS CMS opening txt Files" Watch "JBOSS CMS opening txt Files" New topic
Author

JBOSS CMS opening txt Files

Tanvi Narula
Greenhorn

Joined: Sep 30, 2008
Posts: 9
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

Joined: May 14, 2008
Posts: 5812
    
    7

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.


JBoss In Action
Tanvi Narula
Greenhorn

Joined: Sep 30, 2008
Posts: 9
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

Joined: Jul 20, 2005
Posts: 9932
    
159

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.

[My Blog] [JavaRanch Journal]
Tanvi Narula
Greenhorn

Joined: Sep 30, 2008
Posts: 9
Does not help
 
wood burning stoves
 
subject: JBOSS CMS opening txt Files
 
Similar Threads
Popup - File Download
CMS For Portals
Need Help for implementing save as dialog box for downloading a folder not a file
new portlet window for CMS html file
"Save as" option save Excel file as HTML by default?