ADF--Re-opening Download does not deliver correct content.

I am using JDeveloper 11.1.1.4 and having an issue with downloading files. The first time a user clicks on the command link, the file opens fine. If the user closes the application that the file opened in, and clicks the same link to re-open the file (in this case a PDF) they get an error from Adobe saying the downloaded file is not a supported file type or because the file has been damaged. It seems that it doesn't read all the file. I am using code similar to other posts I've found on this discussion forum. I am adding my java code below, and the Weblogic Server Log messages, and would appreciate any good advice to resolve this issue.
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.domain.BlobDomain;
public class Download {
    public Download() {
        super();
    public void downloadFile(FacesContext facesContext,
                             OutputStream outputStream) throws IOException {
        String mime = null;
        ExternalContext extContext = facesContext.getExternalContext();
        DCBindingContainer dc =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        System.out.println("Before getting iterator");
        DCIteratorBinding iter =
            dc.findIteratorBinding("hot_biz_docs_view1Iterator");
        ViewObject vo = iter.getViewObject();
        Row r = vo.getCurrentRow();
        BlobDomain bDomain = (BlobDomain)r.getAttribute("Document");
        String file = r.getAttribute("FileName").toString();
        String ext = file.toLowerCase();
        System.out.println("In MimeTypes:" + ext);
        if (ext.endsWith(".pdf")) {
            mime = "application/PDF";
        } else if (ext.endsWith(".doc")) {
            mime = "application/msword";
        } else if (ext.endsWith(".docx")) {
            mime =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        } else if (ext.endsWith(".xls")) {
            mime = "application/vnd.ms-excel";
        } else if (ext.endsWith(".xls")) {
            mime =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        } else if (ext.endsWith(".txt")) {
            mime = "text/plain";
        } else if (ext.endsWith(".ppt")) {
            mime = "application/vnd.ms-powerpoint";
        } else if (ext.endsWith(".rar")) {
            mime = "application/octet-stream";
        } else if (ext.endsWith(".zip")) {
            mime = "application/zip";
        } else if (ext.endsWith(".jpg")) {
            mime = "image/jpeg";
        Long length = bDomain.getLength();
        HttpServletResponse response =
            (HttpServletResponse)extContext.getResponse();
        response.setHeader("Content-Disposition",
                           "attachment;filename=\"" + file + "\"");
        response.setContentLength((int)length.intValue());
        System.out.println(mime);
        response.setContentType(mime);
        InputStream in = null;
        try {
            in = bDomain.getBinaryStream();
            outputStream = response.getOutputStream();
            byte[] buf = new byte[1024];
            int count;
            while ((count = in.read(buf)) >= 0) {
                outputStream.write(buf, 0, count);
                if (count <= 0) {
                    System.out.println("End if while loop");
                    break;
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
        in.close();
        outputStream.flush();
        outputStream.close();
        response.flushBuffer();
        facesContext.responseComplete();
        System.out.println("closed and responseComplete");
    }<Aug 22, 2011 4:11:11 PM CDT> <Error> <HTTP> <BEA-101083> <Connection failure.
java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '0' bytes instead of stated: '3544' bytes.
     at weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength(ServletOutputStreamImpl.java:446)
     at weblogic.servlet.internal.ServletResponseImpl.ensureContentLength(ServletResponseImpl.java:1432)
     at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1511)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1462)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
     Truncated. see log file for complete stacktrace
>
<Aug 22, 2011 4:11:11 PM CDT> <Error> <HTTP> <BEA-101104> <Servlet execution in servlet context "ServletContext@33250642[app:LIB_Test module:LIB_Test-LibTestVC-context-root path:/LIB_Test-LibTestVC-context-root spec-version:2.5]" failed, java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '0' bytes instead of stated: '3544' bytes..
java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '0' bytes instead of stated: '3544' bytes.
     at weblogic.servlet.internal.ServletOutputStreamImpl.ensureContentLength(ServletOutputStreamImpl.java:446)
     at weblogic.servlet.internal.ServletResponseImpl.ensureContentLength(ServletResponseImpl.java:1432)
     at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1511)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1462)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
     Truncated. see log file for complete stacktrace
>

You need to close the blob stream, otherwise you can't read it again.
Use the blob.closeInputStream() method on your blob.
Timo

Similar Messages

  • Downloading file not the correct contents

    Hi,
    I have a link on another page the take me over to the page that contains the code below:
    <CFOUTPUT>
    <CFSET FPATH = #GetDirectoryFromPath(ExpandPath("*.*"))#>
    <cfdirectory directory="#FPATH#" name="FILES" action="LIST">
    <TABLE>
    <CFLOOP Query="FILES">
    <TR><TD>
    <CFIF #FILES.NAME# EQ "test.cfm">
    <A href="#FILES.NAME#"> #FILES.NAME# 
    <cfheader name="Content-Disposition" value="attachment;filename=#FILES.NAME#">
    </A>
    </CFIF>
    </TD>
    </TR>
    </CFLOOP>
    </TABLE>
    </CFOUTPUT>
    When I select the test.cfm link, a dialog box appears asking to either Save or Open the file.
    The issue is the file, test.cfm, contents is not what is being saved or displayed when Open is selected.
    Is there something I'm missing?
    Thanks,
    Mike

    I am trying to download a text file, not a cfm file.
    Mike

  • Page does NOT load correctly in FIREFOX

    My HOME page does not RELOAD correctly in FIREFOX when when
    the link is clicked on from another page in my little "2 page"
    site.
    BUT if I click on the BACK button it loads CORRECTLY
    It works correctly in IE
    Here is the Home page:
    http://www.quicksubmitbrokerswholesale.com/
    Here is page 2 where clicking on the link in FIREFOX loads
    incorrectly:
    http://www.quicksubmitbrokerswholesale.com/submitforpricing.html
    What do I need to TWEAK to make it work OK in FIREFOX?
    Thanks in advance

    Here is the crux of all your problems:
    <!-- Fireworks 4.0 Dreamweaver 4.0 target.
    You built the site in Fireworks, and a very old version at
    that, and then
    imported the site into DW. Graphics apps like Fireworks and
    Photoshop
    produce bloated, convoluted code and fragile structures. If
    you want a
    worthwhile site you will have to start over. Create only your
    graphics in FW
    and build the entire site in DW. Be cautioned though such an
    old version of
    DW won't produce a site consistent with today's standards.
    You really should
    upgrade if you want to deliver value to your client.
    Walt
    "electro-dud" <[email protected]> wrote in
    message
    news:gb2k07$9v4$[email protected]..
    > My HOME page does not RELOAD correctly in FIREFOX when
    when the link is
    > clicked
    > on from another page in my little "2 page" site.
    > BUT if I click on the BACK button it loads CORRECTLY
    >
    > It works correctly in IE
    >
    > Here is the Home page:
    >
    http://www.quicksubmitbrokerswholesale.com/
    >
    > Here is page 2 where clicking on the link in FIREFOX
    loads incorrectly:
    >
    http://www.quicksubmitbrokerswholesale.com/submitforpricing.html
    >
    > What do I need to TWEAK to make it work OK in FIREFOX?
    >
    > Thanks in advance
    >
    >

  • Open Hub does not work after upgrade

    We just upgraded our BW production system from 3.0b into 3.5 and we are running support package level 09. Now we are facing serious problems with Open Hub.
    After upgrade Open Hub delivering data from infocube into
    csv-files does not work. When running the InfoSpoke it
    will deliver 0 data records even though it should bring considerable amount of data.
    There is no error message or short dump, it just do not deliver any data. InfoCube has data in place and it is available for reportoing. Extraction is made in FULL-mode and there is no transformations. Funny thing is that extraction from ODS or InfoObject works perfectly fine.
    Has anyone idea how to solve this?
    Thanks in advance,
    JL

    We ran into the same issue as Jari Laine today.
    We just upgraded our BW sandbox environment from 3.0b into 3.5. We are running support package level 13, though. Now we are facing serious problems with Open Hub.
    After the upgrade, our Open Hub which delivers data from an info cube into CSV-files does not work any more.
    When running the Info Spoke it will deliver 0 data records even though it should bring a considerable amount of data.
    There is no error message or short dump, it just does not deliver any data. The Info Cube has data in place and it is available for reporting.
    The Extraction is made in FULL-mode and there are no transformations.
    Has anyone an idea how to solve this?
    Thanks in advance,
    Marc

  • Index does not work correctly in Firefox

    I use WebHelp in Robohelp and had created my Index with the
    index wizard. I recently had complaints about wrong topics opening
    when using the index. This does not happen with content. I have not
    looked closer at search to see if it is happening here.
    When I went back to troubleshoot, I discovered that all the
    links were correct. Further investigation showed that the problem
    was only happening in Firefox not in IE. The problem also did not
    occur all the time. I then realized that it was isolated to topics
    within books or secondary level topics. The first time that you
    click on a link that is a sublevel in your TOC it would go to the
    main topic (book level). The breadcrumb only shows that level. But
    the next time you would click on a link it would go one level
    further (topic page level). So, if you clicked on the link twice,
    the first time it would go to the level above and the second time
    it would go to the correct level. (First click breadcrumb AA>BB
    and the second click AA>BB>CC. The first click should take it
    to the second example, not the first.) This only happens in Firfox.
    I am viewing it in Firefox 3.0.1. Is there a work around for this?
    I do not know how to correct it. The only solution I have is to
    eliminate the index altogether which would not be fun since I also
    have a custom created skin that includes the index that would need
    to be redesigned.

    Welcome to the forum.
    When you say delete the index, I think you mean delete the
    TOC?
    This is a known problem with Firefox. You have books with
    links to topics. If you remove those and have the required topic
    immediately below the book, the problem will go away.
    See other posts and my site.
    Please post a bug report as Adobe need to fix this.
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

  • Why can I not import pictures any more? Lightroom says "Your Lightroom 5 64-bit does not work correctly"

    Why can I not import pictures any more?
    Lightroom says "Your Lightroom 5 64-bit does not work correctly"
    Technical informations:
    PC with Windows 7 64-bit, Lightroom 5.7.1 64-bit installed.
    What I have done:
    I downloaded the newest LR 5.71 and installed it again - mode repair; without success
    I checked my PC with Norton 360: full scanning and optimizing registry
    I restarted the PC and than I installed the LR 5.7 again - repair
    Trouble 1:
    Two days ago I could work with my LR 5 and to import pictures from a SD was no problem. Now I can start LR 5 and I can watch/modify pictures, but as soon as I try to import new pictures LR 5 stops and gives the message "your LR 5 64-bit does not work correctly - searching for solution". I have not changed anything in my computer since lasttime LR 5 worked properly, only the registry was optimized by Norton 360.
    Trouble 2:
    I live in Switzerland and my language ist German. I dit not find a place where I can present my problem in German, e.g. a phone number oder email-address oder german-chat. My English is to week for a discussion for computer problems and do understand it.
    Help:
    I would very appreciate if anybody can help me, either to trouble 1 or to trouble 2. Thanks.

    Sehen Sie diesen Beitrag:
    Photoshop CS4 & Lightroom 2.6 X64 funktionieren nicht mehr
    Wacom Tablet-Treiber-Problem?

  • The web site of Adobe does not show correctly in FireFox

    I have a bizarre problem.  The site of Adobe (including where I can download the flash player) does not show correctly in FireFox and I only see it as a text HTML page, but without most images (typically, for instance, I do not see the image "Download now" but see a text line "Dowload now", and so on...
    This seems to specifically affect the Adobe web site as I have no problme for other web sites (so far).
    It is something specific to FireFox as  I do have the problem with Internet Explorer.
    The problem persis even if I restart FireFox without any add-on (safe mode).
    Any suggestion ?

    Does this only happen in Firefox?  What do you see with Internet Explorer or Chrome?  If it is only Firefox, I'd try these steps in this order:
    1. Clear your cookies and cache
    2. Reset your Firefox settings
    3. Make a new profile
    Chris

  • Satellite M645-S4050: built in camera does not work correctly

    My built in camera does not work correctly.
    It does not have any kind of effect on and it captures pictures and videos as if some kind of thermal camera was on.
    Also some videos I load up on youtube look like this.
    I have been researching for an answer but can't find it, please help me.

    All you can do is to test it with latest webcam driver.
    Remove preinstalled camera software and install latest version offered on Toshiba download page.
    If the same happen again visit nearest Toshiba service and show them how it looks like. Maybe the cam must be exchanged.
    In the past I have used several Toshiba laptops with built in cam but I have never saw something lke this.

  • Mozilla Addons site does not load correctly in IE - impala-min.js

    It seems that the Mozilla Addons website does not load correctly any more in IE and the errors below are generated on XP (IE8), Windows 7 (IE9) and Windows 8 (IE10). It seems to be a JavaScript error from the messages from webpage error popup.
    Browsing any addon specific page (NoScript, Menu Editor, Flashblock, etc) all seem to hang with the
    'loading-more.gif' graphic showing constantly and none of the lower tabs (Version Information, etc) will open to show information.
    I know technically this isn't a Firefox issue but I use IE to check version compatibility of addons before loading in Firefox. Perverse I know but hey it works, or used to until very recently.

    This wasn't a question about loading Firefox extensions in IE which would not have a clue about the contents of the .XPI file.
    This was about an error on the addons page which seems to stop ANY of the pages from showing details of the extension such as user reviews, developer feedback and version history...
    Viewing from Firefox they just show as compatible and versions over 3.6 but from IE you could see what versions the extension was compatible with, ie 9 thru 15 which is far more helpful when deciding which to deploy in a workplace.
    Have tried this on four different machines with the same outcome for viewing in IE!

  • 11x17 tabloid does not print correctly

    I am using an HP Photosmart printer model 8550, my previous printer was an HP Photosmart 8750. That printer died and the 8550 is the newer model of the same printer. When trying to print an 11X17 document in tabloid, the page does not print correctly nor does it show in preview mode correctly. The page shifts to the upper left corner so that the left side and top of the document do not print. If you scale down the size you can get it to print the whole documentm but you cannot get it to use the whole 11x17 page. Anyone else with this problem and a solution? Thanks!

    [email protected] wrote:
    I am having a similar problem.  I have windows XL,
    and a hp Deskjet 9800.  I have been using PM 6.5 ever since it came out.  I publish a newsletter using tabloid fold in half, under booklet.  So it is a really a 4 page document.  It has always done fine until this week.  It prints the copy in reduced format that would fit on a 8 1\2 x 11.  I have tried every setting possible, with no success.  Today I downloaded the trial 7.0 version, it does the same thing.  I went back and printed old versions that a 3 & 4 years old they won't print right now, either.
    It's old software and new operating system/printer drivers. You are unlikely to get any help from Adobe or HP but you can try.
    Create a PDF and print that as it's unlikely the DeskJet has PS mode.
    BTW, booklet printing is far easier with ISO paper sizes.
    Move on up to InDesign while you can still get a big discount with PM Licence number.

  • Sometimes JavaFX form (BorderPane) does not show correctly

    We have a problem with a JavaFX application running on Java 7. Sometimes a form (BorderPane) does not show correctly – it seems to be transparent (i.e. content previously shown at the same place is still visible). Controls seem to be present and respond to events – e.g. we can close the form by blindly clicking the appropriate button. Once the issue happens it is persistent, i.e. next time we open the form, it behaves the same.
    We have no reproducible scenario leading to the issue. It just happens here and there – we have not been able to identify any pattern yet.
    Additional information:
    the form (BorderPane) is loaded during application start-up but it is not shown initially,
    to show the form we remove previous contents from a StackPane and add the form instead,
    to hide the form we do the reverse.
    Do you have any ideas how to diagnose the problem? Where to look first? What kind of diagnostic code could we put in the application that would help us?

    I am unaware of any such issue being reported previously.
    Without a reproducible test case, you are unlikely to get much assistance.
    Other than the creation of a minimal test case which reproduces the issue, I could not even advise how you might go about diagnosing and fixing your issue.
    There were many bug fixes implemented for Java 8.
    I advise you to upgrade your test environment to the latest Java early access release (currently Java 8u40) and test to verify if your issue replicates in that version.
    If the issue still reproduces, create a bug report which includes your test case and full environment details.

  • Download does not launch

    download does not launch

    Thank you.  The download directions did not include the part about double clicking the desktop Elements icon, double clicking the elements icon within the box that opened and then clicking on "install."  Okay, so i am not computer savvy, but the directions gave the impression that the download was complete after following the supplied instructions.  Who knew?  I did not want to duplicate a download, so was apprehensive to take this action.  Did it anyway out of frustration and it worked.  Obviously, the application was not entirely downloaded.   Now, i get to learn a whole new application as IPhoto bites!  I spent hours and hours, days upon days scanning and editing old family photos in IPhoto only to learn that the program re-sorted my photo order when i tried to make copies for family.  I lost my edits, lost my photo notes and had to retrieve my entire library before presenting several hundred multi generational family photos to everyone in my extended family!  Hopefully, this application will be an improvement!
    Thanks again for taking the time to respond!

  • After recent upgrade Mozilla will open but does not connect - I have Norton Antivirus.

    After recent upgrade Mozilla will open but does not connect. I have uninstall/reinstalled several times. I have NortonAntivirus.

    It is possible that your security software (firewall, anti-virus) blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full, unrestricted, access to install for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls
    *https://support.mozilla.org/kb/fix-problems-connecting-websites-after-updating
    Do a malware check with several malware scanning programs on the Windows computer.
    Please scan with all programs because each program detects different malware.
    All these programs have free versions.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender:<br>http://windows.microsoft.com/en-us/windows/using-defender
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked
    *https://support.mozilla.org/kb/troubleshoot-firefox-issues-caused-malware

  • I just upgraded to Mavericks and suddenly youtube does not display correctly although other sites work fine. I am using the newest MacBook Air. Any suggestions?

    I just upgraded to Mavericks and suddenly youtube does not display correctly although other sites work fine. I am using the newest MacBook Air. Any suggestions?

    Hi ..
    Open System Preferences > Flash Player then select the Advanced tab.
    Click Delete All under Browsing Data and Settings
    Back to Safari. Press Command + Option + E to empty the Safari cache.
    Quit and relaunch Safari, try a video.

  • Animated Gif Image does not render correctly on screen

    I have added animated gif image to the scene it does not render correctely.it shakes on the screen. plz give me any suggestion
    i use following code
    Image logo= new Image(getClass().getResourceAsStream("images/image.gif"));
    logoLabel.setGraphic(new ImageView(logo));

    Hello user,
    I think gif are rendered smoothly.
    Are you sure you are not making many object of same images everytime?
    Thanks.
    Narayan

Maybe you are looking for

  • OD Down because SSL problems

    My OD is down because the CA athority can't be found. I'm running 10.8.5 with Server 2.2.x OD won't start anymore. I replaced the Certificate with a new valid one. But i can't assign the Cert to OD again. How te resolve this.

  • Webpage error for Apple User in OWA

    Exchange 2010- User with Apple Mac gets the following errors when trying to respond to an email in OWA.  No Windows users have indicated any problems. Safari:  A problem occurred with this webpage so it was reloaded. Chrome: Aw, Snap!  Something went

  • Dateiformat JPEG/JFIF von Photoshop

    Hallo allerseits, ich muß (ohne Photoshop!) aus einer mit Photoshop gespeicherten JPEG/JFIF-Datei die "Objektbeschreibung" (aus den Datei-Informationen) auslesen.Kennt einer von Ihnen den genauen Aufbau des Photoshop-spezifischen Blocks innerhalb der

  • Oracle HTMLDB general question

    I am currently evaluating HTMLDB as a potential Business Intelligence Portal platform for my company. After playing with it for couple of weeks, I felt that it is far from being a BI platform. It is not a portal either. (I know HTMLDB is not designed

  • Adding rows in existing table

    Hi gurus, Please tell me how to add  row to the existing table where we enter conditions while defining the calculation schema. i.e. Control data screen for calculation schema.