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 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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 5823
    
    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: 10069
    
163

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBOSS CMS opening txt Files