Problem with downloading file as an attachment

In my application, I use the following code to download a file from the content server WebCenter as an attachment:

public void downloadDocumentAsAttachment(ActionEvent event) {
     try {
          String   contentId = (String) event.getComponent().getAttributes().get("ContentId");
          ContentObj content = this.contentManager.getContentFromContentId(contentId);
           
          FacesContext  facesCtx = FacesContext.getCurrentInstance();
          HttpServletResponse response = (HttpServletResponse) facesCtx.getExternalContext().getResponse();
          response.reset();
          response.setHeader("Content-Disposition", "attachment; filename=\"" + content.getName() + "\"");
          response.setContentType(content.getContentType());

          ServletOutputStream out = response.getOutputStream();
          IOUtils.copy(this.contentManager.downloadContent(contentId), out);
          out.flush();

          facesCtx.responseComplete();

     } catch (Exception ex) {
          ex.printStackTrace();
     }  
}

The "contentManager' is my custom object implemented with CRMI to manage interaction with WebCenter Content server. I tried to print the length of the content to make sure there is actually an InputStream returned by the my object. However, my problem is that on Firefox and Chrome, I do not see a file download dialog box. To be precise, the Chrome, the screen just flashed once and nothing did. On Firefox, I saw the following dialog box:

Capture.PNG

If I click 'Return', the screen also flashed once and nothing happens as well.

At first, I tried to make use of '< af:fileDownloadActionListener >', I am able to 'see' the file. However, the problem is that my page is completely replaced by the file. I had to click on the back button to return to the original page, and sometimes it has not also that the page has expired. As a result, I implement the download of files as an attachment for the moment.

I would be very grateful if you could show me what I did wrong .

Best regards

James Tran

Thank you very much for spending your time helping me, Johny!

I found the solution. Take a look at the documentation for the "", I now noticed the following description of the attribute "filename":

proposed for the object file name. If you select a "Save file" dialog box typically appears, whether it is ultimately up to the browser. If this isn't the case together, the content will usually line displayed in the browser if possible.

Earlier, I didn't specify the "filename" I read somewhere that it is optional. Thus, my file was posted online to download as an attachment instead.

Tags: Java

Similar Questions

  • Problem with downloading files

    Hello

    I copied and pasted the example to the next (TechNote
    http://www.adobe.com/go/5534a12f) and he ran with the library MultipartRequest to O'Reilly that was suggested by the article. I managed to download small files that were under 1 megabyte, but has been unsuccessful in downloading large files. In addition, when downloading moved, no error messages don't come to Flex. Am I missing something or the download feature does not work with large files? If this is not the case, what should I do?

    This has been resolved.

  • Problems with downloading files

    I have Win8. I had Adobe Reader 11 that worked perfectly well download any file in any destination. Now when I try to download it either 1) completely blocks my computer 2) States, I don't have the latest version. I tried to download the new DC Adobe which I have no interest in and when open the domain controller downloaded file he totally locked up my computer. I like to turn it off.  Why Adobe 'fix' something that didn't need to be fixed? I need to download new files and cannot. Any solution?

    Cynthia, you can try to use this tool first remove all traces of your computer:

    http://labs.Adobe.com/downloads/acrobatcleaner.html

    Then you can download the full Setup offline reader for the version you want from

    http://get.Adobe.com/reader/Enterprise/

    After downloading, restart your computer and run the Setup program before anything else.

  • Cause a problem with downloading files

    Hello

    I'm new to APEX. I'm stuck with a problem in my application.

    In my application, there is a page that will show you the information about users in an organization. Also a facility to add a new user. In the new user screen, there is a control of uploading files with several other controls.

    The question is I download a file and click on submit button to download the files, the files are downloading with success, but as the page is argue, he is redirected to the details of the user to the screen that i donot want to do.

    Welcome any quick response to solve this problem.

    Thank you
    Satish.

    Well, then you should have two buttons on your page, one to create (CREATE or ADD or something similar) and another for the update (UPDATE or SAVE or APPLY the CHANGES or something similar)

    Lets say after update, you want to stay on the same page, then make sure you have a conditional branch that runs when you click the button to update and targets for the same page. And after inserting if you want to return to the home/report page, so make sure that you have another conditional branch that runs when you click the button CREATE and host/report page targets. You must have two conditional branches on your page.

    If this does not help, please provide all of the buttons that you have in your page, branches and what you try to do :-)

    Kind regards
    Hari

  • I have problems with pdf files, sent to me by e-mail, download doc on my canon printer and the creation of pdf file to send.

    Original title: pdf files

    I am running microsoft windows xp home edition 2002. I always have problems with pdf files, sent to me by e-mail, download doc on my canon printer and the creation of pdf file to send. I use microsoft works Task Launcher 2004 edition.

    Is there an easy way to pass so I can handle pdf files?  Can anyone help?

    Thank you Tim

    Hello

    Please provide us with more specific information on the issue. Your post is a bit confusing.

    If you need to open the PDF files, you will need to install a PDF reader.

    If you try to print in PDF format, you must install Adobe Reader.

    Reference: http://www.adobe.com/downloads/

    THIRD WARNING:
    Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

  • Problem with the file naming

    I can change my names of files successfully, mp3s to be precise, uniformly. Windows Explorer or Altap Salamander, there really is no problem with my file name.

    The problem starts to appear when I put my mp3s in my playlists (VLC, WMP, media player in my cell phone). The old file name keeps showing even though I have already changed the original/source file.
    For example, a song I downloaded bears the title "WTF * Chris Brown-int ' love ' so I changed it to 'Chris Brown - International Love' since that's how I name not all the thousands of my mp3s. But when I added the song to my playlist, the original title is one that appears and not the new. This case is the same with most of my Media Player.
    Is it possible for me to keep my desired/preferred file names when using the Media Player files? It's really so frustrating.

    Usually, media players like WMP does not show the name of the file of the song, but display the title and artist in the song tags (also known as metadata). To change these tags in WMP, add your songs to the library WMP library, right click on the tag you want to edit, and select Edit.

    You can also change the labels of the song with external tools such as Mp3tag.

  • A12E5: PROBLEM WITH DOWNLOAD CC

    A12E5: PROBLEM WITH DOWNLOAD CC

    Hi PurpleTrial,

    A12E5 is a download error. Please follow the steps:

    Windows:

    Access the Files(X86) C/Program Files/Adobe/OOBE /Common and rename it to OOBE.old.

    Task Manager open, go to process and close all Adobe services running (Acrotray, AAMUpdate Notifier) http://www.howtogeek.com/66622/stupid-geek-tricks-6-ways-to-open-windows-task-manager/ .

    Download CC Office and try to install again: https://creative.adobe.com/products/creative-cloud .

    If the problem persists what run selective startup and try to install the CC Office: http://windows.microsoft.com/en-in/windows-vista/run-selective-startup-using-system-config print .

    Mac:

    Navigate to Library/Application Support/Adobe/OOBE and rename to OOBE.old.

    Go to Applications/Utilities and trash Application Manager and creative cloud desktop folder.

    Download and install CC Office again. If the problem still persists, then restart the Mac start-up and try reinstalling: http://helpx.adobe.com/x-productkb/global/start-safe-boot-mode-mac.html .

    Kind regards

    Romit Sinha

  • Problem with downloading of applications and updates

    Hello

    I get the error when you try to download certain applications from the Mac App Store.

    And when I try to update applications.

    Here is a log from the console:

    storedownloadd [493]: * the Assertion failure in French-[CheckPreflightOperation verifyDistributionAtURL:allowsDevSign:allowsUnsigned:osVersionToBeInstalled: err or: distributionController:], /Library/Caches/com.apple.xbs/Sources/Commerce/Commerce-462.9/CommerceKit/Check PreflightOperation.m:291

    I have a month old Macbook Pro. I have no problem with downloading the applications from my old Macbook on the same network.

    What should I do?

    Hello..

    Start Safe Mode removes the system caches that can help.

    Upper left corner of your screen, click on the Apple  > Shut Down.

    After your Mac stops, wait 10 seconds, then press the power button.

    As soon as you hear the startup tone, hold down the SHIFT key. You must press the SHIFT key as soon as possible once you hear the startup tone, but not before.

    Release the SHIFT key when you see the gray Apple logo and progress indicator.

    Once you are in Mode without failure, return to the menu Apple . In the drop-down list, click: reboot


    Then try the App Store.

    On Safe Mode

  • problems with downloads

    I have this function of issues, can not download microsoft updates, cannot run the validation tool, if I try the windows update I get redirected to a blank page with the message cannot display the page or the web page of google or other, can not download my antivirus mcafee (it will only download if I call mcafee) I tried microsoft help I worked with a member of the technical support , always the same, if I try to download an antispyware software does the same thing (the page cannot...) I finally download malwarebytes antispyware with no reported problems, if I run mcafee antivirus, there is no issue reported, the worst part is the case in all my 5 computers 3 2 xp running Vista, what is the problem! I have internet through a clearwire wireless router, it is connected to a phone and then router to a linksys wireless router, which could be

    OK, I fixed my problems with downloads, here is what I got I hollow by clearwire internet a wireless modem, it is connected to a modem uta200 I got from t-mobile, so I can have the fixed telephone line, finally, is a wireless router linksys that I am connected to my desktop computer and of course I use with my laptop I tried to connect my clearwire modem direct to my computer and didn't work, then I tried to connect it to a modem, tmobile and worked but if I try to connect it to router linksys did not work so I called linksys they tried twice and failed, but has the 3rd time the technician reset the router and worked , so right now I have much internet access with no. fails all the

  • Windows Media player on my machine does not run some AVI files. How can I check what the problem with AVI files. Files are running in other utilities of free ware

    Windows Media player on my machine does not run some AVI files. How can I check what the problem with AVI files. Files are running in other utilities free ware. Also, windows Explorer does not display dimension and other video related information for the file. Y at - it a tool that can indicate what exactly is the problem with the file.

    Ritu

    Hello

    1. you get any error message?

    2. don't you make changes to the computer before the show?

    Please follow the steps from the link below.

    http://support.Microsoft.com/kb/279242

  • I just did a check of norton power Eraser which revealed that I have a problem with the file ntsd.exe.

    original title: problem with file ntsd.exe

    I just did a check of norton power Eraser which revealed that I have a problem with the file ntsd.exe. Does anyone have suggestions about what to do to fix it? Thank you very much.

    Hi JohnABuckley,

    • Are you facing any problem on the computer?

    Ntsd.exe is a process belonging to the Microsoft symbolic debugger that lets you debug applications in user mode.

    As the link below, it says that there is a risk that Norton Power Eraser can select some legitimate programs for removal. You should carefully review the analysis results page before deleting the files. I suggest that you don't delete the file unless you are facing problems with the computer.

    https://www-secure.Symantec.com/Norton-support/JSP/help-solutions.jsp?LG=English&CT=us&docid=20100824120155EN&product=home&version=1&PVID=f-home

  • When starting a warning pops up saying he had problems with the file: XBD EXE that can be done to correct it?

    When starting a warning pops up saying he had problems with the file: XBD EXE that can be done to correct it?

    Hi r13hunter,

    It seems that some programs running on the computer fails to load at startup of the system. Try these steps and check the result.
    Step 1: Find the program that causes this problem and delete or fix
    a. Click Start, type msconfig and press to enter.
    b. click on Startup tab, in the list, search for the path of the xbd.exe file and the associated program.
    c. Once you have found the path of the item and the associated program, repair or reinstall the program.
    See Uninstall or change a program

    Step 2: If the problem persists, perform the clean boot to find this good program that is causing the problem to the system startup
    a. open the article: http://support.microsoft.com/kb/929135
    b. Article, follow "step 1: perform a clean boot" the implementation of these measures will disable all programs not Microsoft currently running on the computer.
    c. restart the computer and check if the problem persists.
    d. If the problem does not persist in the boot, it means that some programs non-Microsoft is the source of the problem.
    e. to find the program that is causing the problem, try "step 2: enable half the services" to "step 6: resolve the problem.
    f. Once you find the culprit, check if there is any updates to update or fixes to the program. If you find, install them and check the difference or reinstall the latest program.
    g. Article, follow "step 7: reset the computer to start as usual.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I have problems with downloading the Lightroom app! What is the location of the appropriate installation?

    I have problems with downloading the Lightroom app! I have already many programs Adobe works on my PC and I have a cloud of Adobe license. But now, with the installation of Lightroom, I get the following error:

    Exit code: 7

    Please see specific errors below for troubleshooting. For example, ERROR: DF014...

    -------------------------------------- Summary --------------------------------------

    -0 fatal Error (s), 1 Error (s)

    -Payload: Adobe Lightroom 6.0.0.0 {8048A5DF-8A70-5BE1-954B-E0FDE1BD0D0D}.

    ERROR: DF014: unable to create the symbolic link to ' \\XC-DC-01\Users\Patricia\... \Desktop\Adobe Lightroom.lnk "(Seq 6641).

    When I go to the solution, then it says: rerun the installation. Select a different installation location.


    But I tried to select all the other folders on my computer for the last two weeks and it still not working? Update other programs is not a problem, then I don't understand what goes wrong? What is the location of the appropriate installation? Why it changed on my computer?

    Can you help me with a solution? Thank you!

    Hello

    Please see Exit Code 7 Installing and errors ' Exit Code: 6 "," Exit Code: 7 "|"» CC, CS6, CS5.5

    Hope that helps!

    Kind regards

    Sheena

  • I have problem with Muse files when you work at home with my laptop and when I open the files again in my work with my IMac.

    I have problem with Muse files when you work at home with my laptop and when I open the files again in my work with my IMac.

    I do: when I am uncomfortable with the laptop I save the files on the laptop, then on my external hard drive. Then, when I'm at work, I opened the drive, but the Muse says every time, that so many links in the 'active' is missing. And it takes a lot of time to get all the missing link. Like today I had to open a file of Muse from the external hard drive, and there are about 100 links that are missing.

    How can I solve this problem

    the best thing if you are a user of creative cloud is to store the files in a folder in your account of cloud instead of transferring the files from one computer to another.

    If you are not a Subscriber cc then Dropbox or iCloud will work as well.

  • I just looked at problems with importing files from nikon D810 in LR 5.7 it pop a window saying it can't read the files to work on an imac 27 "yosemite on my mac pro running after several times he finally managed to read files and import them into LR

    I just looked at problems with importing files from nikon D810 in LR 5.7 it pop a window saying it can't read the files to work on an imac 27 "yosemite on my mac pro running after several times he finally managed to read files and import them into LR, I never had this problem before there was a sort of update that could from cause?

    What is the destination folder that the date be underneath?  In the top right it says users who suggests, you try to put the photos on top of your username instead of under your username.  Maybe that's the problem.  So change your folder in the drop-down list at the bottom right of what it should be rather than users, and if you're going to show us the destination of your photos at least scroll through the list of folders down right so that we can see which is the white highlight.

    Here is how mine looks like if I want to put my photos imported under my subfolder users - Steve - photos by date:

Maybe you are looking for

  • Hidden items in security downloads

    I am concerned about the hidden items that are loaded down with the application of security updates. I don't like Apple sends apps that I will never use, but cannot get rid of once they are installed. Are these these hidden apps? What happens if you'

  • active site not highlighted in the bookmarks bar, until I have to move the cursor

    I noticed that when I click on a favorite site remains highlighted when the website opens. If I work next to the bookmark sidebar scroll bar it then highlights the active site.How can I keep the active site highlighted without touching the slider bar

  • Screensaver not working only not with the hot corner

    I used to have my screensaver set to start with the upper left corner of my screen using the feature 'hot corner '. However, lately, he doesn't. I tested it with all the other corners, and it does not work. I tried other functions with the hot corner

  • J9M35UA: serial number

    Hello How can I change the time on my computer? How can I make my picture favorite as my wallpaper?

  • Generating events

    I need a Subvi to generate the user events that must be received by hand VI. Currently, I use the user event and would like to find how to send this event generated at hand VI? In other words the Subvi will generate events and if there is a listener