Invalid File after Downloading from Database using JSP/JDev 10.1.2

Hi, i got a problem when i download a file from my blobColumn in database.
Well, actually i got no problem in reading the file out of database, but when i download this file, there are 3 more bytes then in the original one in Database...
Here's my java-code in the jsp-page i used as "save as" field:
Hashtable ht = Dokument.createDOK(request);
String dateiname = (String)ht.get("Dateiname");
byte[] fileBytes = (byte[])ht.get("Dokument");
ByteArrayOutputStream ba = new ByteArrayOutputStream();
ba.write(fileBytes);
// RESPONSE
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment; filename=\"" + dateiname + "\"");
// DOWNLOAD
OutputStream outs = response.getOutputStream();
ba.writeTo(outs);
outs.flush();
outs.close();
}catch(Exception ex){
ex.printStackTrace();
for testing i used a simple text file with 28bytes:
begin----
Test Zeile 1.
Test Zeile 2.
end-------
after downloading this file it looks like:
begin----
Test Zeile 1.
Test Zeile 2.
end-------
There are 3 bytes 0A(hex) at the beginning...
I dont know why.
after closing "outs" i made system.out for checking the amount of bytes in "fileBytes"-Array, and it was correct, just the 28 bytes like in the file from the Database.
But i actually dont get, why there are 3 more bytes at the beginning after downloading it.
The main problem is, some other files like word or excel documents cannt be opened, because of this 3 bytes at the beginning, and they seem to be invalid.
Would be glad if someone can help me, got really stuck and have no idea any more.
Thanks
Sebastian

Dont someone has a solution, or got a similar problem ?
Thought about it could be a bug in the basic java classes of JDev 10.1.2
but i dont really know...
Have no idea left.
Sebastian

Similar Messages

  • Export to Excel from Database using JSP

    Hi Experts,
    I'm using below jsp code to export from an Oracle table to Excel using JSP.
    Every time I run this code I get the exception - "java.lang.OutOfMemoryError: Java heap space".
    I need to download around 8000+ records of the table containing 60 columns.
    I have increased Heap space but still the exception. Below is the code for your reference (I have mentioned only 30 columns where as there are 60 columns in actual). Pls help me what could be the other possible ways or suggest me any alternate code.
    Pls note - Some of the terms like "<serverip>", MySchema, myfile, COL names are changed for confidentiality.
    "D:\\Myfolder\\Excelfolder\\Final.xls" exists my the local machine.
    The code works until some 4000 records & after that throws the exception.
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@<serverip>:1521:WISTGDEV", "user", "user@123");
    Statement statement = connection.createStatement();
    String filename = "C:\\Myfolder\\Excelfolder\\Final.xls";
    String strQuery1 = ("select * from Myschema.myfile");
    ResultSet rs = statement.executeQuery(strQuery1);
    HSSFWorkbook hwb = new HSSFWorkbook();
    HSSFSheet sheet = hwb.createSheet("sheet1");
    HSSFRow rowhead = sheet.createRow((short)0);
    rowhead.createCell((short) 0).setCellValue("COL1");
    rowhead.createCell((short) 1).setCellValue("COL2");
    rowhead.createCell((short) 2).setCellValue("COL3");
    rowhead.createCell((short) 3).setCellValue("COL4");
    rowhead.createCell((short) 4).setCellValue("COL5");
    rowhead.createCell((short) 5).setCellValue("COL6");
    rowhead.createCell((short) 6).setCellValue("COL7");
    rowhead.createCell((short) 7).setCellValue("COL8");
    rowhead.createCell((short) 8).setCellValue("COL9");
    rowhead.createCell((short) 9).setCellValue("COL10");
    rowhead.createCell((short) 10).setCellValue("COL11");
    rowhead.createCell((short) 11).setCellValue("COL12");
    rowhead.createCell((short) 12).setCellValue("COL13");
    rowhead.createCell((short) 13).setCellValue("COL14");
    rowhead.createCell((short) 14).setCellValue("COL15");
    rowhead.createCell((short) 15).setCellValue("COL16");
    rowhead.createCell((short) 16).setCellValue("COL17");
    rowhead.createCell((short) 17).setCellValue("COL18");
    rowhead.createCell((short) 18).setCellValue("COL19");
    rowhead.createCell((short) 19).setCellValue("COL20");
    rowhead.createCell((short) 20).setCellValue("COL21");
    rowhead.createCell((short) 21).setCellValue("COL22");
    rowhead.createCell((short) 22).setCellValue("COL23");
    rowhead.createCell((short) 23).setCellValue("COL24");
    rowhead.createCell((short) 24).setCellValue("COL25");
    rowhead.createCell((short) 25).setCellValue("COL26");
    rowhead.createCell((short) 26).setCellValue("COL27");
    rowhead.createCell((short) 27).setCellValue("COL28");
    rowhead.createCell((short) 28).setCellValue("COL29");
    rowhead.createCell((short) 29).setCellValue("COL30");
    int index=1
    String name="";
    while(rs.next())
    System.out.println("Inside while");
    HSSFRow row = sheet.createRow((short)index);
    row.createCell((short) 0).setCellValue(rs.getString(2));
    row.createCell((short) 1).setCellValue(rs.getString(3));
    row.createCell((short) 2).setCellValue(rs.getString(4));
    row.createCell((short) 13).setCellValue(rs.getFloat(5));
    row.createCell((short) 4).setCellValue(rs.getString(6));
    row.createCell((short) 5).setCellValue(rs.getString(7));
    row.createCell((short) 6).setCellValue(rs.getInt(8));
    row.createCell((short) 7).setCellValue(rs.getString(9));
    row.createCell((short) 8).setCellValue(rs.getString(10));
    row.createCell((short) 9).setCellValue(rs.getString(11));
    row.createCell((short) 10).setCellValue(rs.getString(12));
    row.createCell((short) 11).setCellValue(rs.getFloat(13));
    row.createCell((short) 12).setCellValue(rs.getFloat(14));
    row.createCell((short) 13).setCellValue(rs.getFloat(15));
    row.createCell((short) 14).setCellValue(rs.getFloat(16));
    row.createCell((short) 15).setCellValue(rs.getFloat(17));
    row.createCell((short) 16).setCellValue(rs.getFloat(18));
    row.createCell((short) 17).setCellValue(rs.getFloat(19));
    row.createCell((short) 18).setCellValue(rs.getFloat(20));
    row.createCell((short) 19).setCellValue(rs.getFloat(21));
    row.createCell((short) 20).setCellValue(rs.getFloat(22));
    row.createCell((short) 21).setCellValue(rs.getString(23));
    row.createCell((short) 22).setCellValue(rs.getString(24));
    row.createCell((short) 23).setCellValue(rs.getString(25));
    row.createCell((short) 24).setCellValue(rs.getString(26));
    row.createCell((short) 25).setCellValue(rs.getString(27));
    row.createCell((short) 26).setCellValue(rs.getString(28));
    row.createCell((short) 27).setCellValue(rs.getString(29));
    row.createCell((short) 28).setCellValue(rs.getString(30));
    index++;
    rs.close();
    FileOutputStream fileOut = new FileOutputStream(filename);
    hwb.write(fileOut);
    fileOut.close();
    connection.close();
    catch(Exception e)
    System.out.println(e.getMessage());
    e.printStackTrace();
    Thanks in advance,
    Venky
    Edited by: Venky_86 on Apr 15, 2009 12:06 AM

    Its is an obvious thing...POI is known to need a lot of memory (the reason for that is most likely the OLE document format, which is quite complex).
    I would have used something like the below to see if that can address my client's requirement.
    public exportExcel(String fileName){
       Connection connection = null;
       Statement statement = null;
       ResultSet rs = null;
       PrintWriter out = null;
       int index=1;
       try{
         out = new PrintWrite(new FileWriter(fileName));
         connection = DbUtils.getConnection();
         statement = connection.createStatement();
         rs = statement.executeQuery("select * from Myschema.myfile");
         out.prinln("<table>");
         out.println("<th>COL1</th>");
         out.println("<th>COL2</th>");
         out.println("<th>COL3</th>");
         out.println("<th>COL4</th>");
         out.println("<th>COL5</th>");
         out.println("<th>COL6</th>");
         out.println("<th>COL7</th>");
         out.println("<th>COL8</th>");
         out.println("<th>COL9</th>");
        out.println("<th>COL30</th>");
         out.println("<thead>");
         out.println("<tbody>");
         while(rs.next()){
              out.println("<td>"+index+"</td>");
              out.println("<td>"+rs.getString(2)+"<td>");        
              out.println("<td>"+rs.getString(3)+"<td>");        
              out.println("<td>"+rs.getString(4)+"<td>");        
              out.println("<td>"+rs.getString(5)+"<td>");        
              out.println("<td>"+rs.getString(6)+"<td>");        
              out.println("<td>"+rs.getString(7)+"<td>");        
              out.println("<td>"+rs.getString(8)+"<td>");        
              out.println("<td>"+rs.getString(9)+"<td>");        
              out.println("<td>"+rs.getString(30)+"<td>");        
         out.println("</tbody>")     
         out.println("</table>");    
         out.flush(); 
       }catch(Exception exp){
           exp.printStackTrace();
       }finally{
           if(out != null)
            try{out.close();}catch(Exception e){}
             if(rs != null)
               try{rs.close();}catch(Exception e){}
            if(statement != null)
               try{statement.close();}catch(Exception e){}
             if(connection != null)
               try{connection.close();}catch(Exception e){}
    }and you can simply export the file using the method
    ApplicationUtils.getInstance().exportExcel("c:/export/myapp/ApplicationTable.xls");If you are using Office 2000 and above you should able open it as an excel worksheet without any problems.
    Hope that help :)
    REGARDS,
    RaHuL

  • Corrupt aac files after downloading from iTunes!

    Hi,
    the download manager of iTunes is bad! If downloads are interrupted and resumed later (lack of electricity supply, disruption of the Internet connection), then aac files are not valid! Such a file stops playing in the middle of the song, for example. Yesterday I checked my library (with Parallels Desktop + Win XP + foobar2000 + foo verifier) and I found 45 invalid aac files! All of these files I recently downloaded (iTunes Match matching process).
    Why iTunes don't check the file size or a checksum after downloading???

    Yes. I've had and continue to have this problem of a small number of songs getting downloaded corrupt when updatings songs via iTunes Match.
    Deleting and re-downloading from iTunes Match is the only solution I have found for the problem as I am having it: the songs ARE corrupted for me, and it's not just a metadata problem. When I open the songs in an audio editing program you can see that the audio just isn't there: the data stops before the end of the song (somewhere between 50% and 70% through the piece, usually). So copying it to another computer or re-importing it won't fix anything.
    The problem is that iTunes doesn't KNOW which of the songs I've matched-then-downloaded via iTunes Match are bad, and I won't know either until I happen to play one that skips before it ends.
    Here's the only solution I've found that will inspect these songs one at a time and list the bad ones:
    Create a Playlist of all songs you've downloaded (upgraded) via iTunes Match.
    Plug in an iPod (etc.) and wipe out whatever songs are on it already.
    In the iTunes setting for that iOS device, tell it to recompress the songs to 128k AAC as it puts the songs onto the iOS device.
    Now sync that entire Playlist to the device and wait.
    Result: all songs that cannot be down-converted by iTunes to 128k AAC (because the song data is bad) will be listed in the resulting error dialog.
    Here's the total suck part: iTunes doesn't let you save that list of errors off to a text file. You have to do one or more screen captures and save off the list, then manually go find those songs, delete them and re-download them from iTunes Match. Total PIA but it's the best I have come up with, since I can find no other utility or means to batch-check that these files are valid.

  • Can not find a movie file after downloading from iTunes.

    After downloading a movie in iTunes Store (with iTunes Extra feature), I don't know why I can't find the main movie file on my hard drive (only iTunes Extra file was showed). What can I do?

    I can't find a movie I downloaded and iTunes wants me to purchase it again.

  • Viewing Images from Database using JSP/ SQLJ

    Dear Friends,
    I could manage to write an image into a BLOB Field in the Oracle
    Database. I could even manage to read that image from the
    database but i am doing it by reading the BLOB data and writing
    it into a file with 'gif' or 'jpeg' extension.
    I would like to know how to read the BLOB data dynamically in
    cache and display it on the JSP page in the browser without
    creating a file on the disk.
    Thanking you,
    Sarwottam

    Thanks for replying,
    Can you please elaborate on your suggestions ?
    If possible can you provide a sample code that would help me understand better?
    Thanks again.
    Sarwottam

  • Can't open pdf files after downloading from Safari 6.0.5

    I was wondering whether anyone else has encountered this bug. Ihave a retina MBP with Safari and Firefox. If I save a pdf to the desktop via Safari I get the following message when I try to open it "There was an error opening this document. The file is damaged and could not be repaired".
    When I download the same file via Firefox, it opens no problem.
    It would, therefore seem to be a Safari 6.0.5 pdf problem, rather than an Adobe Acrobat Pro (11.0.3).
    I have tried with both extension displayed and not displayed options, no difference.
    Can anyone suggest anything?
    Thanks for reading.

    I encountered the same problem.  In my case, the culprit was a plug-in in the Internet Plug-Ins sub-folder of my User Account's Library folder.
    Here's how I proceeded, based on a suggestion by Carolyn Samit here:
    <https://discussions.apple.com/thread/5117605?start=0&tstart=0>
    1. Open the Finder.
    2. In the Finder menu bar, click on the heading Go.  Scroll down to "Go to Folder," and then click the mouse button again.
    3. Copy the following phrase:
    /Library/Internet Plug-Ins
    and then paste that phrase into the field in the navigation window that appeared at the end of Step 2.
    3. Click Go.
    4.  If you find a plug-in named AdobePDFViewer.plugin, drag it to the Trash.
    5. Quit and then relaunch Safari.  Then try to load in Safari a PDF from a web site.  Then try saving it.  Once saved/downloaded, try opening the PDF.
    When I followed this procedure, the corrupted-PDF problem went away, thanks to Ms. Samit's suggestion.

  • Fetch Data from Database using JSP

    Dear friends,
    I am developing a portal for my College. The theme is to automate student details.
    Here i have Screens for Posting, Editing , Viewing.
    In Editing: I fetch the data from the backend using select query.
    In the address field: I have value as "Big House".
    The user keyed with double quotes when he keyed.
    During extraction of the data i put the value inside a textbox as
    <input type=text name=st1 value="<%=res.getString("street1")%>">
    Here,
    the value becomes as
    <input type=text name=st1 value=""Big House "">
    Here, you can notice that Big house i prefixed by double -double quotes.
    The value should be Big House but the values is empty.
    What i should. ???
    Thanks in Advance.
    Rengaraj.R

    Try this:
    <%
    String addr = res.getString("street1");
    //escape the double quotes from the address
    addr = addr.replaceAll("[\"]",""");
    %>
    <input type="text" name="st1" value="<%=addr%>">

  • Hi, I upgraded to OX X Mountain Lion, and now I can't upload any pictures from iphoto/desktop to email, etc.  After I choose my file and hit "attach file" to upload, it says: "Invalid File Specified".  I am using jpg, so I'm confused. Any suggestions?

    Hi, I recently upgraded to OX X Mountain Lion, and now I cannot upload any of my pictures from iphoto or even my desktop to email, etc.  After I choose my file and hit "attach file" to upload, it says: "Invalid File Specified".  I am using jpg, so I'm confused. Any suggestions?

    Not having a media card in your BlackBerry may affect your ability to transfer media files onto it. There is a file size limit of 2.86MB when transferring files into device memory. http://bbry.lv/9XNuy0
    Have you verified that the applications you are trying to install are supported by your current wireless provider? Unlocked devices from one provider may not have full functionality on another network.
    -FS
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click Solution? for posts that have solved your issue(s)!

  • HT1338 exe files won't open after downloaded from Safari on my Mac OS X 10.4.11

    exe files won't open after downloaded from Safari on my Mac OS X 10.4.11

    I use the free Unarchiver: http://unarchiver.c3.cx/unarchiver
    I have just tested it on a self-extracting Windows Internet Explorer and it opened it first time on my Mac.
    However, as you have been told, normally Windows executable files cannot be opened or used on Macs.

  • Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder., Is there

    Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder., Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder.

    Bridge will do the job. View > Sort > ByType. Then you can choose a group of one type and put the files in a separate folder.

  • How to copy file to another server from database using FTP in oracle

    How to copy file to another server from database using FTP in oracle.
    Please do the needfaul.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Not to mention that some FTP servers can return more than one return message per operation whereas others may return one message for the same operation.I had the problem using the LIST command to determine if a file exists on the server. Cannot be determined via the FTP server's return code. Which means parsing and checking the text response from the server to the command. And this vary from server to server.
    But the basics were quite easy to code. The entire package is 500 lines, includes comments and blank lines for formatting, and supports the basic FTP client command set. Not really a complex piece of software to write - but I found that many developers seem to think that writing network socket software is complex. Not really the case...Mine's a big larger, but incorporates functionality similar to what Chris provided in his, such as being able to use SQL to query a remote file using pipelined functions, or functionality to write the results of a query directly to a remove file.
    :)

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • Error trying to run the Sample Code Virtual Private Database using JSP's

    Hi.
    I`ve downloaded the Virtual Private Database using JSP's example from the Oracle9iAS Security - Sample Corner (http://otn.oracle.com/sample_code/deploy/security/9i_security.html)
    I ran the SQL script just fine. I�ve Opened the JDeveloper Flile (security.jws) and tried to Make it (following step 2 on "Run the Application using JDeveloper Environmentinstructions" in the README ) but i get this error:
    Error: unable to copy to output directory, web.xml not found
    It seems that i need the web.xml to run this application, but in the zip file i cannot find any XML file.
    What can i do?.
    Thanks in advance for your help

    Hi,
    the problem seems not to be within your application but in missing files on your embedded OC4J. Just try and unzip the JDeveloper 10.1.3 install again.
    Frank

  • Problem in Font when file is downloaded from query output

    Hi,
    We are facing a problem as we are not able to simulate a scenario at our end where a file is downloaded from a query. The snapshot of the file which is downloaded in excel is shown below. The name displayed below has special characters in it. The actual value for the name is VÁRADI GÁBORNÉ, but when the file is downloaded into excel, the special characters get converted to some different characters and the last character ie É gets converted to “?” and the values for the next column get concatenated to the Name 1 column and all the values move one column left.
    Sold to     Cl     Name 1                                      Sal.per.     Sales doc.
    57983     CD     V&#32629;ADI G&#32603;ORN?00002110       2150451     
    57983     CD     V&#32629;ADI G&#32603;ORN?00002110       2150451     
    The procedure used by the user to download the file from the query is as follows:
    1.     The query is executed in background with file name entered in Save with ID option
    2.     After the job is complete, the file is displayed from the saved list of that query.
    3.     This saved list is then downloaded as .DAT file and then opened with excel.
    Any pointers to solve the problem will be highly appreciated.
    Regards,
    Kaushal Mehta

    Hi,
    There is no problem of device type as when we are testing the query with the same inputs (same variant, same printer), the output to the excel comes correctly. But at the user end, the output does not come out properly. Infact the saved list displayed for that query shows the output to be correct, but when that list is exported to excel, the output gets distorted for the user (not for us).
    Thanks for your inputs,
    Kaushal

  • Experiencing corrupted / unreadable files after download

    I have a quad core mac pro running snowleopard.  Recently I've noticed that I've been having more and more files be unreadable after having been downloaded over the internet.  This happens both after downloading from an internet browser, downloading through a 3rd party downloader client (Continuata), as well as syncing with Dropbox.
    Given the increasing frequency in which I am encountering unreadable files (i.e. when you try to open or move a file and you get a finder error that says the operation can't be completed because the file cannot be read error -36).
    From what I've read this can be due to either software problems or hardware issues.  From my personal experience I get the feeling I'm probably dealing with a hardware problem, but I not sure where to start.  Most of my problems DO seem to occur on a single internal hard drive, but the diagnostic tests I've run speak nothing but love for the health of the drive (disk utility repair, various Drive Genius 3 tools).
    Further information:  I use dropbox and sync many times a day with other peoples shared folders.  I also use Synergy, the mouse/keyboard sharing over the network software (and it's slightly buggy).
    I've repaired permissions a bunch of times, never had any problems to be repaired.  Nor have I had any problems to be repaired when I do repair disk.
    Is it possible my network adapter might be going?  Or some other internal hardware component on the motherboard?

    Mac Pro 65lb tower uses Error Corecting Code (ECC) Memory, so memory problems are not your issue, or you would be getting kernel panic, machine check.
    The individual data blocks on Disk are recorded using an error-correcting code. Simple problems are corrected on the fly, serious problems cause big delays and an I/O Error.
    The communications interfaces use error detection codes, and errors there would cause re-transmission. Repeated problems would slow your connection and eventually cause errors.
    The most likely problem is the type that will be fixed by Disk Utility (Repair Disk). That is, if the free list is incorrect, and a block gets inadvertatly re-used before its time.
    This also could be a problem with "crazy software". If you tend to load up your machine with lots of third-party gadgets, you will make it unstable.

Maybe you are looking for

  • Problem with nokia e51 plugin installation

    hey guys! i have a problem concerning the installation of the plugin for the usage of the nokia e51 with apple isync. (nokia_e51_1v1.dmg) i have mac osx 10.4.11 and isync 2.4. when i tried to install the plugin i got the message that i have to upgrad

  • PO DELETED AFTER MADE GRN AND PAYMENT----SYSTEM ALLOWED

    Dear friends           In our company the user deleted the purchase order after done GRN and made payment. The question is how the system allowed to do it? i checked the system message to stopit but i couldn't found it.so could anyone let me know is

  • Weblogic Server abort suddenly

    Hi, We experienced spontaneous weblogic server abortions. The system configuration is as follows: Microsoft Windows Advanced Server 2000 Weblogic Server 8.1.0 (in production mode) SUN JDK 1.4.1_02 The symptom is that Weblogic server exits without pri

  • Use of Std Price in APO

    Hi All, Please let me know the use of standard price in APO that is updated from R3. Our scenario in APO include DP, CTM, deployment and TLB. We do not run SNP optimizer. As CTM does not recommend based on cost, can std price field be deleted without

  • Consignment Fill up vallid for accounting document

    Hello, I want to create accounting document during Goods issue in Consignmentt Fill up. Actually We want to bill customer at time of consignment fill up. Please suggest for required settings for the same. Regards Amit