Download problem with JSF: Cannot open PDF-file after opening WORD-file

Hello,
I have a JSP (created with Java Studio Creator) which displays a table with links to different files. Some links open PDF-documents, other for instance DOC-files (msword). I download the file as follows:
public String downloadFile(String fileName) {
try {
int dotIndex = fileName.lastIndexOf('.');
String fileExtension = "";
String contentType = "";
if(dotIndex > 0) {
fileExtension = fileName.substring(dotIndex+1, fileName.length());
contentType=CONTENT_TYPES.get(fileExtension.toUpperCase()).toString();
if(!fileExtension.equals("") && !contentType.equals("")) {
// method that reads file to the byte array
byte[] fileContent = getContentOfFile(new File(fileName));
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
response.setContentType(contentType);
response.setContentLength(fileContent.length);
response.setHeader("Content-disposition", "inline; filename=\""+fileName+"\"");
try {
ServletOutputStream out;
out = response.getOutputStream();
out.write(fileContent);
} catch (IOException e) {
e.printStackTrace();
faces.responseComplete();
catch(Exception ex) {
return ("!!!ERROR: downloadFile(fileName) - Could not completely download file "+ fileName + ex.getMessage());
return "";
contentType is application/pdf if it`s a PDF-file or application/msword if it`s a word-file.
fileName contains the full file path.
link-properties:
<ui:hyperlink action="#{showOriginalPDF.hyperlinkShowPDF_action}" binding="#{showOriginalPDF.hyperlinkShowPDF}"
id="hyperlinkShowPDF" immediate="true" onClick="testSubmit()" target="_blank" text="#{currentRow.value['display']}"/>
and the code of the JS-function testSubmit() (without this function I couldn�t get the right row selection in the hyperlink-table):
function testSubmit() {
document.getElementById('form1').submit();
return false;
All pdf-links are working fine and the correct document is displayed in a new browser window. but if I open a WORD-document and after that I click on another link to a pdf-file, the WORD-file is loaded again in the new window. Only if I close the window which contains the WORD-document, I can download the correct pdf after that.
Is something wrong with the response header (I tried "attachment" instead of "inline" too but without effect)?
Can anybody help?

More than you asked for but good stuff. Permissions is buried in there somewhere.
Reading
[Resolve startup issues and perform disk maintenance with Disk Utility and fsck|http://docs.info.apple.com/article.html?artnum=106214]
[Using Disk Utility in Mac OS X 10.4.3 or later|http://docs.info.apple.com/article.html?artnum=302672]
[Disk Utility's Repair Disk Permissions 10.0-10.6|http://docs.info.apple.com/article.html?artnum=25751]
"Try Disk Utility" (modified from [http://support.apple.com/kb/TS1417])
1. Insert the Mac OS X Install disc that came with your computer (Edit: Do not use this disc if it is not the same general version as what you have currently on your computer, e.g. use a Tiger disc for a Tiger drive, not a Panther disc), then restart the computer while holding the C key.
2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
3. Click the First Aid tab.
4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
5. Select your Mac OS X volume.
6. Click Repair. Disk Utility checks and repairs the disk.
Then boot in Safe Mode, (holding Shift key down at bootup; takes longer to boot this way so be patient), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
[Mac OS X: Starting up in Safe Mode|http://docs.info.apple.com/article.html?artnum=107393]
[What is Safe Boot, Safe Mode? (Mac OS X)|http://support.apple.com/kb/HT1564]
[Safe Boot takes longer than normal startup|http://docs.info.apple.com/article.html?artnum=107394]
[Mac OS X 10.4, 10.5- Computer shuts down during Safe Boot|http://support.apple.com/kb/TA24054]

Similar Messages

  • Blank error message with ? appears and PDF does not open in Browser (IE11) when clicking link to open pdf. PC - IE11 Acrobat 9.0

    Blank error message with ? appears and PDF does not open in Browser (IE11) when clicking link to open pdf. PC - IE11 Acrobat 9.0
    Cannot access in browser PDF files unless blank box is closed and then website address is clicked on again in browser address bar and page reloaded.
    Uninstalled Acrobat 9, reinstalled, still same problem.
    Help please!

    Yes I can it only happens in the browser..
    I reinstalled Windows on my machine and started over a couple of weeks ago.
    When my desktop started up I didn’t have Acrobat installed and clicked on a pdf file and the open with xxx dialogue box came open.
    I chose a different program as Acrobat wasn’t installed yet so it associated pdf files with another program.
    Later Installed Acrobat and couldn’t associate the pdf file with acrobat so I went into Folder Options and manually associated PDF files with Acrobat.
    Ever since then I get the error when something is downloaded and opened in the browser.
    Works fine everywhere else and when I cancel the blank error, highlight the web address and press enter to reload it works 90% of the time.
    Not sure what to do..

  • Facing problem with logo in the PDF attachment when sending mail...

    hi friends,
    i'm facing problem with logo in the PDF attachment to the mail.
    my requirement:
    1. enter spool number and mail id in the selection screen.
    process:
    1. now the program will fetch the spool data and converts it to PDF.
    2. but when i'm trying to send mail with this PDF as attachment.
    when i open the PDF file from the mail, logo is not coming properly (looks disturbed).
    can anyone help me how to resolve this issue...
    thanks in advance, murashali.

    hi dinakar, thanks for your mail...
    logo looks good in spool/script/smartform.
    even it look good when i download this spool to pdf and to the presentation server as pdf file.
    i'm using CONVERT_OTFSPOOLJOB_2_PDF.
    when i used CONVERT_ABAPSPOOLJOB_2_PDF, is gives a msg - 'spool number not found'.
    here i'm using folloing code to pass pdf to the function module: SO_NEW_DOCUMENT_ATT_SEND_API1.
    code:
    Transfer the 132-long strings to 255-long strings
      lt_mtab_pdf[] = pdf[].
      LOOP AT lt_mtab_pdf INTO lwa_mtab_pdf.
        TRANSLATE lwa_mtab_pdf USING ' ~'.
        CONCATENATE lv_gd_buffer lwa_mtab_pdf INTO lv_gd_buffer.
        CLEAR lwa_mtab_pdf.
      ENDLOOP.
      TRANSLATE lv_gd_buffer USING '~ '.
      DO.
        lwa_mess_att = lv_gd_buffer.
        APPEND lwa_mess_att TO lt_mess_att.
        CLEAR lwa_mess_att.
        SHIFT lv_gd_buffer LEFT BY 255 PLACES.
        IF lv_gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    NOTE: problem i believe is with ''.  i'm getting this tilt symbol () in my pdf internal table.  here in the above code the line   TRANSLATE lv_gd_buffer USING '~ ' is changing the existing tilt to space.  so my logo is getting disturbed.
    even i tried with REPLACE this tilt with other char, but it doent work.
    can you give any idea...

  • I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after saving as from word 2007 - I uninstalled Pro X1 and now when I save as from word 2007 to PDF it will

    Can anyone help with this - do I have to uninstall Reader and then reinstall?

    I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after "saving as" from word 2007 - I uninstalled Pro X1 and now when I "save as" PDF from word 2007 to PDF it will save the document as a PDF but will not open the document to display after publishing - I have to got to where the file has been saved to view the new PDF document - this is really annoying - do I have to delete adobe reader and reinstall it - adobe needs to look at this conflict with acrobat pro as I have even gone it to properties and tried to have adobe reader as the default PDF program - the main issue is that I cannot view the PDF after publishing it from word 2007

  • I am having a problem with the FireFox browser. I have attached two files that best describe the problem. I have labeled them A & B. A is the way it should lo

    I am having a problem with the FireFox browser. I have attached two files that best describe the problem. I have labeled them A & B. A is the way it should look and B is what happens after I have I opened several tabs. I can get it back to normal if I click on VIEW than click on customize. When the customize window appears FireFox returns to its normal state. I than click on the done box and go back to what I have been doing. I tried resetting FireFox back to default settings, but that did not correct the problem.
    This began happening about a month ago. Is there a way I can fix this problem? Thanks for your help.I don't know how to attach my 2 attachments that shows the problem I am having.
    [email address removed to protect your privacy and security]
    <! [email protected] -->

    I found the images here: https://support.mozilla.org/en-US/questions/977542#answer-501598

  • FF 6.0 doesn't open pdf-links, after clicking on "open pdf" error message says file not supported or damaged. IE opens file all right. Please advice.

    Firefox 6.0 doesn't open pdf-links after clicking on "open pdf". I frequently need to do literature searches and I need to view pdf files in the browser. After clicking on the pdf - link of a file the main options are to open or download the pdf. Every time I try to open a pdf-file a blank page and an error message appears saying the file would not be supported or is damaged. IE, however, opens the file all right. I tried various changes in the security and cookie settings without success. Please advice.

    Hi SGckc,
    This document is almost certainly a dynamic XFA form. Unfortunately, our mobile Reader does not support displaying or filling such forms. The application that produces this form embeds this message into the document so that non-supportive viewers (like ours) will display this "error" page when the document opens. I do realize that this is confusing and I would like to add some additional detection to our Reader for this case. However, we've avoided doing this for fear of confusing users even further. Your feedback helps though. Hopefully we'll find a way to detect this case and present a better message to the user like: This form is not supported by the mobile version of the Adobe Reader. Please open and fill it on the non-mobile version of the Adobe Reader for Windows, Linux or Mac OSX.
    Thank you for contacting us!
    Pat

  • Problem with iDVD - cannot burn DVD.

    Problem with iDVD - cannot burn DVD.
    Self has a MacBook Pro, which al new software.
    My problem is, when my burn a slideshow, prop process ever before burning.
    Box show: Multiflexing and burning: write Lead-in, then the process stops and ejects the disc.
    I have burn a Movie test – no problems.
    Self use Verbatim DVD-R
    Who can help - what should I do?

    How did you create the slideshow and get it in iDVD?
    As a general comment try following this workflow to separate the encoding and burning processes:
    Once you have the project as you want it save it as a disk image via the  File ➙ Save as Disk Image  menu option.  This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image and launch DVD Player and play it.  If it plays OK with DVD Player the encoding was good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    OT

  • No place to Double Click visible on pdf file-after opening a password-protected pdf

    No place to Double Click visible on pdf file-after opening a password-protected pdf

    Thanks Pat for your interest.
    Actually I am using Windows 8 (Not 8.1) and Adobe Reader Version XI (11.0.06)
    Now, the exact problem I am facing is that there are certain types of pdf files I am being sent which are Password pritected (it may not be a necessary condition, i don;t know) and after I have keyed-in the correct password, it flashes the message- "Double-click here to open your file". Now while using the earlier versions of Adobe (or maybe Windows) I used to see a peculiar Pin-shaped object on the screen, double-clicking which used to open the file. That object is somehow missing this time, so I have no place to double-click. Therefore I am not able to open the file.I may add that I have recently moved to Windows 8 from XP, so my knowledge of Windows 8 is not up to mark. Can you please help?

  • Working with bootstrap css file after opening the browser

    working with bootstrap css file after opening the browser when i came back on working on bootstrap my computer started hanging and opning new tabs  and showing message " A caused the program to stop working correctly.Windows will close thoe program and notify you if  solution is available"

    Hi Geetha,
    1.) button problem:
    i don't know how you open the form - when you do it with a XML file maybe you packed the wrong XML file into your addon installer.
    2.) the flickering can be a problem of formatted searches or interacting with other addons.
    when addon a. changes a field it can be that addon b. does something because of the event from addon a.
    the same can happen when you have formatted searches that do something when a field changes.
    ok - that are my last tipps for this day
    good night
    David

  • Can anyone help me with an iWeb problem? I cannot save the site after making changes. I receive this error: "website.sites2 could not be saved"

    Can anyone help me with an iWeb problem? I cannot save the site after making changes. I receive this error: "website.sites2 could not be saved"

    You could try duplicating the Domain.sites2 file and launch this in iWeb. Delete the last page you edited and try saving. If that doesn't work, undo and try deleting another and so on...
    If you can find the problem page you would only have to rebuild it rather than the whole site.
    The other possibility is to create a new site on the same domain file and drag each page in turn down to it from the top site and try to save each time.

  • I have a problem with searching page, whenever i try to open any page a blank paper cums appear only written custom search google in English

    i have a problem with searching page, whenever i try to open any page a blank paper cums appear only written custom search by google this one is not such as my google home page
    == This happened ==
    Not sure how often
    == i use to search any page like movies or etc

    Well, it seems waiting is not my strong suit..! I renamed a javascript file called recovery to sessionstore. This file was in the folder sessionstore-backups I had copied from mozilla 3 days ago, when my tabs were still in place. I replaced the sessionstore in mozilla's default folder with the renamed file and then started mozilla. And the tabs reappeared as they were 3 days ago!
    So there goes the tab problem. But again when I started mozilla the window saying "a script has stopped responding" appeared, this time the script being: chrome//browser/contenttabbrowser.xml2542
    If someone knows how to fix this and make firefox launch normally, please reply! Thank you

  • Problems with JSF and included subviews

    Hi everybody,
    I' ve got a problem with JSF and included subviews which makes me going
    crazy. I've got no clue why my web-pages are represent wrongly. The only
    tip I've got is that it must be connected with the kind I do include my JSF-pages.
    When I use <%@file="sub.jsp"%> my pages are are represent right. When I use <jsp:include page="Sub.jsp" /> or <c:import url="Sub.jsp" /> ( mark: the usage of flush="true" or flush="false" doesn't matter )
    my pages are represent wrongly.
    The usage of tags like f:facet or f:verbatim were also included but didn't point to an solution.
    I searched the whole Sun Developer Forum and some other web-sites for any solution for my problem but the given hints and clues didn't help. Now I'm trying to post my problem directly in Sun's Forum in hope to get help.
    My environment is the following:
    JAVA JDK 1.5 Update 4
    Tomcat 5.5.9
    JSLT 1.1
    Sun JSF 1.1
    Win 2K
    Here's my code:
    Main.jsp
    <%@ page language="java"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%
              String path = request.getContextPath();
              String basePath = request.getScheme() + "://" + request.getServerName()
                        + ":" + request.getServerPort() + path + "/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
         <base href="<%=basePath%>">
         <meta http-equiv="pragma" content="no-cache">
         <meta http-equiv="cache-control" content="no-cache">
         <meta http-equiv="expires" content="0">   
         <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
         <meta http-equiv="description" content="This is my page">
         <link rel="stylesheet" href="stil.jsp" type="text/css" />
    </head>
    <body>
         <f:view>
              <h:form>
                   <div class="table">
                        <div class="tr">
                             <h:outputText styleClass="tdleft" value="value 1"/>
                             <h:outputText styleClass="tdinfo" value="value 2"/>
                        </div>
                        <div class="tr">
                             <h:outputText styleClass="tdleft" value="value 3"/>
                             <h:outputText styleClass="tdinfo" value="value 4"/>
                        </div>
                   </div>
              </h:form>     
              <jsp:include page="Sub.jsp" />
         </f:view>
    </body>
    </html>Sub.jsp
    <%@ page language="java"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <f:subview id="subview">
         <h:form>
              <div class="table">
                   <div class="tr">
                             <h:outputText styleClass="tdleft" value="value 11"/>
                             <h:outputText styleClass="tdinfo" value="value 22"/>
                   </div>
                   <div class="tr">
                        <h:outputText styleClass="tdleft" value="value 33"/>
                        <h:outputText styleClass="tdinfo" value="value 44"/>
                   </div>
              </div>
         </h:form>
    </f:subview>stil.jsp
    <%@page contentType="text/css"%>
    <%
        String  schwarz     = "#000000",
                grau1       = "#707070",
                grau2       = "#c0c0c0",
                grau3       = "#e0e0e0",
                grau4       = "#e8e8e8",
                grau5       = "#fdfdfd",
                blau        = "#0000dd",
                tuerkis     = "#00cfff";
        String  liniendicke = "1px",
                linienart   = "solid";
        String allgemeineTextFarbe           = schwarz;
        String allgemeineHintergrundFarbe    = grau3;
        String infoTextFarbe                 = blau;
        String fieldsetRandFarbe             = blau;
        String fieldsetRandDicke             = liniendicke;
        String fieldsetRandArt               = linienart;
        String hrLinienFarbe                 = blau;
        String hrLinienDicke                 = liniendicke;
        String hrLinienArt                   = linienart;
        String inputAktivHintergrundFarbe    = grau5;
        String inputReadonlyHintergrundFarbe = grau4;
        String inputPassivHintergrundFarbe   = grau4;
        String inputPassivFarbe              = schwarz;
        String inputRandFarbe1               = grau1;
        String inputRandFarbe2               = grau5;
        String inputRandDicke                = liniendicke;
        String inputRandArt                  = linienart;
        String inputButtonHintergrundFarbe   = grau3;
        String legendenFarbe                 = blau;
        String linkFarbe                     = blau;
        String linkAktivFarbe                = tuerkis;
        String linkBesuchtFarbe              = blau;
        String linkFocusFarbe                = tuerkis;
        String objectGitterFarbe             = grau5;
        String objectGitterDicke             = liniendicke;
        String objectGitterArt               = linienart;
        String tabellenGitterFarbe           = grau5;
        String tabellenGitterDicke           = liniendicke;
        String tabellenGitterArt             = linienart;
    %>
    <%-- ----------------------------------------------- --%>
    <%-- Textdarstellung mittels der Display-Eigenschaft --%>
    <%-- in den Tags div und span                        --%>
    <%-- ----------------------------------------------- --%>
    *.table {
        display:table;
        border-collapse:collapse;
    *.tbody {
        display:table-row-group;
    *.tr {
        display:table-row;
    *.td,*.tdright,*.tdleft,*.tdinfo,*.th {
        display:table-cell;
        padding:3px;
        vertical-align:middle;
    *.td,*.th {
        text-align:center;
    *.tdright {
        text-align:right;
    *.tdleft {
        text-align:left;
    *.tdinfo {
        color:<%=infoTextFarbe%>;
        text-align:right;
    *.th {
        color:<%=infoTextFarbe%>;
        font-weight:bold;
    }thanks in advance
    benjamin

    Hello Zhong Li,
    many thanks for your post, but it didn't work.
    My problem is that the JSF-Components im my included or imported
    JSP-Pages does not accept any kind of style or styleClass for
    designing. The components take over the informations for colors
    but not for alignment.
    When I take a look at the generated JAVA-Source in $TOMCAT/WORK/WEBAPP for my sub.jsp ( sub.java )
    it seems that the resulting HTML-page would be presented correctly.
    But later when I start the application via Firefox or Mozilla the html-sourcecode is totally wrong.
    In my example I create a simple grid with 2 rows and 2 columns.
    Both columns contains JSF-Outtext-Components and are included with div-tags.
    The generated Sub.java shows that the text would be setted in the div-tags. Unfortunately the html-sourcecode represented by my browser shows that jsf-text is not setted in the tags but in the <h:form> tags. The div-tags are neither rounded by <h:form> nor containing the JSF-OutText-Components.
    Any clue?
    Many thanks Benjamin
    Here is the html-code from Firefox:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
         <base href="http://polaris21:8080/webtest/">
         <meta http-equiv="pragma" content="no-cache">
         <meta http-equiv="cache-control" content="no-cache">
         <meta http-equiv="expires" content="0">   
         <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
         <meta http-equiv="description" content="This is my page">
         <link rel="stylesheet" href="stil.jsp" type="text/css" />
    </head>
    <body>
         <form id="_id0" method="post" action="/webtest/Main.faces" enctype="application/x-www-form-urlencoded">
              <div class="table">
                   <div class="tr">
                        <span class="tdleft">value 1</span>
                        <span class="tdinfo">value 2</span>
                   </div>
                   <div class="tr">
                        <span class="tdleft">value 3</span>
                        <span class="tdinfo">value 4</span>
                   </div>
              </div>
              <input type="hidden" name="_id0" value="_id0" />
         </form>     
          <form id="SUB:_id5" method="post" action="/webtest/Main.faces" enctype="application/x-www-form-urlencoded">
               <span class="tdleft">value 11</span>
              <span class="tdinfo">value 22</span>
              <span class="tdleft">value 33</span>
              <span class="tdinfo">value 44</span>
              <input type="hidden" name="SUB:_id5" value="SUB:_id5" />
         </form>
         <div class="table">
              <div class="tr">
              </div>
              <div class="tr">
              </div>
         </div>
    </body>
    </html>

  • Hello,i have a macbook air and i downloaded warblade(with torrent)and when i try to open it opens in textedit.it shows a looooong text and signs.

    hello,i have a macbook air and i downloaded warblade(with utorrent)and when i try to open it opens in textedit.it shows a looooong text and signs.

    It does sound like you downloaded the Windows version.  OS X doesn't know what to do with file and just opens it up in Text.  You can download the Mac version directly from C/NET - Download.com:
    http://download.cnet.com/Warblade/3000-2099_4-10834246.html?tag=mncol;2

  • Hello, i have an problem with my adobe id. If i open everywhere adobe program it will now the serialnumer. can you help me?

    Hello, i have an problem with my adobe id. If i open everywhere adobe program it will now the serialnumer. can you help me?

    Ask for serial number http://forums.adobe.com/thread/1234635 has a FAQ link
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work

  • Hello Apple? How do i fixed my problem with my ipad apps every time i open that apps it takes 10min. to play the games ant its getting LOST MODE and the ipad system is crashing

    How do i fixed my problem with my ipad apps every time i open that apps it takes 10min. to play the games ant its getting LOST MODE and the ipad system is crashing

    We are fellow users here on these user-to-user forums, you're not talking to iTunes Support nor Apple.
    Have you tried closing all apps via the iPad's multitasking bar and then doing a soft-reset and seeing that helps ? To close all apps :
    iOS 7: double-click the home button to open the taskbar, and then swipe or drag each app's screen from there up and off the top of the screen to close it, and click the home button to close the taskbar.
    iOS 6 and below : from the home screen (i.e. not with any app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of each app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    Soft-reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

Maybe you are looking for