Servlet Download Problem

Hi,
I am using a servlet for downloading my octet-stream file from server. Its working fine when the size of the file is above 0 bytes. If the file size is 0 bytes the file is not downloaded and I am getting http 502 error in server.
Anybody have solution for this issue?
Here is my code:
HttpSession session = null;
response.reset();
session = request.getSession();
try {
String fileTest = null;
String file = null;
fileTest = (String) session.getAttribute("DOWNLOADSESSION");
file = fileTest.substring(fileTest.lastIndexOf("/") + 1,fileTest.length());
response.setContentType("application/binary");
response.setHeader("Content-Disposition","attachment; filename=" + file + ";");
FileInputStream fin = new FileInputStream(fileTest);
ServletOutputStream out = response.getOutputStream();
byte[] b = new byte[fin.available()];
int len = 0;
while ((len = fin.read(b)) != -1) {
out.write(b, 0, len);
out.flush();
out.close();
return;
catch (Exception e) {
LOG.error("Exception while processing request::"+e.getMessage());
}

836428 wrote:
Hi,
I am using a servlet for downloading my octet-stream file from server. Its working fine when the size of the file is above 0 bytes. If the file size is 0 bytes the file is not downloaded and I am getting http 502 error in server.What is returned by fin.available() for a 0 byte file?
Why do you want to send 0 byte files? What use are they?

Similar Messages

  • IPhone app store downloading problem

    I have iPhone app store downloading problem (iOS 5). I could not download or update any software successfully from yesterday. Every app shows "waiting for download" but nothing happen for two days. It seems my app store does not connect to server. I use same account in my iPad, but it works normal. So, what happen to my iPhone? Please help me!

    Hold the home button and lock button for 10 seconds to reboot the iPhone.

  • Servlet Compilation Problem !

    Hi,
    I am just starting to learn servlets and I got problem in compiling them. I got compilation error in
    import javax.servlet.*;statement. Seems that the compiler cannot find the servlet package. I got J2EE 1.4 beta installed on my machine but there is no servlet.jar package. I am using J2SDK 1.4.1_02, J2EE 1.4 beta and Tomcat 4.1.24.
    Can anyone help me with my servlet compilation problem?
    Thanks in advance!
    Josh

    servlet.jar is here :
    <tomcatdir>\common\lib
    add it to your compiler classpath

  • Adobe reader download problem on mac.  when i try to download reader it says i need adobe air.  when i try to download adobe air it says it's no longer available or supported.  i deleted the old air because i got a message saying i needed to delete it.

    adobe reader download problem on mac.  when i try to download reader it says i need adobe air.  when i try to download adobe air it says it's no longer available or supported.  i deleted the old air because i got a message saying i needed to delete it. what should i do?  my operating system is Mac 10.7.5

    You don't need Adobe AIR to download or install Adobe Reader.
    Try downloading the offline installer from http://get.adobe.com/reader/enterprise/

  • Rental movie download problems

    I
    I trie to download a movie ,it says it has downloaded buy won't let me play it

    I have been having downloading problems for the last few days and despite all the tricky advice. iTunes jut can't solve the problem.
    These are some of the actions taken:-
    Uninstall and reinstall iTunes
    Turn off Anti Virus (didn't like that one!) Then uninstall anti virus!!!!!! No!!!
    Change preferences in iTunes
    Update iTunes...etc etc etc etc etc!  ZIP!
    Think I will go back to Big Pond Movies as is a lot easier and less stressful.
    Do I Tunes think everyone has telescopic eyesight? The text is so small (just like all their printed matter) have to use a magnifying glass.
    As you can detect, I am less than happy.
    Graham

  • Servlet chaining problem..

    import java.io.*;
        import javax.servlet.*;
        import javax.servlet.http.*;
        public class Deblink extends HttpServlet {
          public void doGet(HttpServletRequest req, HttpServletResponse res)
                                       throws ServletException, IOException {
            String contentType = req.getContentType();  // get the incoming type
            if (contentType == null) return;  // nothing incoming, nothing to do
            res.setContentType(contentType);  // set outgoing type to be incoming type
            PrintWriter out = res.getWriter();
            BufferedReader in = req.getReader();
            String line = null;
            while ((line = in.readLine()) != null) {
              line = replace(line, "<BLINK>", "");
              line = replace(line, "</BLINK>", "");
              out.println(line);
          public void doPost(HttpServletRequest req, HttpServletResponse res)
                                        throws ServletException, IOException {
            doGet(req, res);
          private String replace(String line, String oldString, String newString) {
            int index = 0;
            while ((index = line.indexOf(oldString, index)) >= 0) {
              // Replace the old string with the new string (inefficiently)
              line = line.substring(0, index) +
                     newString +
                     line.substring(index + oldString.length());
              index += newString.length();
            return line;
    What is pre request fo above code to work.
    I had tried this many time but it is not working, what will be calling servlet look like

    And can you explain why your title is "Servlet chaining problem"?

  • ** 6i Download problems - Product Management speaks **

    Firstly on behalf of the 6i Product Management team let me appologise for the problems you have been experiencing with Technet and specifically with downloading 6i.
    I watch this forum and answer questions time permitting whenever I can, this forum (along with comp.databases.oracle.tools and ODTUG) are monitored by Product Management.
    You need to understand that Oracle is a very big company and that getting all the little parts to work seamlessly together sometimes doesn't work as well as it should, so please be assured that Tools PM is working as hard and as fast as it can to ensure that 6i is available for you to download.
    I have made enquiries today to find out what is happening at Technet. This is a division of Marketing based out of the US HQ, the PM teams have no responsibility for the management or maintenance of this site, we merely monitor mail lists and post our new software when complete.
    I am waiting for information on the action plan to resolve the performance and download problems being experienced by the Developer community.
    In response to some of the comments posted about downloading
    It is obvious that 6i has been out for a WHILEActually this is not true, it has been available for download for a while, but not orderable..
    Product Release Point Dates:
    (1)
    Release to MFG - 24-MAR-00 (This date is used by engineering and is the start of the 16-week period for the 1st patchset.) THE PRODUCT IS NOT ORDERABLE YET.
    (2)
    Release to PRG - 14-APR-00 (This is the M&D hand-off date for the Tools CD Pack.) THE PRODUCT IS NOT ORDERABLE YET.
    (3)
    Between 6:00PM PST and midnight 27-APR-00 - R6i, Windows, was added to the Oracle Store and officially orderable.
    I have seen many posted messages, iTARS, etc referencing the availability of downloading forms updates, availablity of getting patchesAs you will see from the information above, this is not possible, patch one for 6i will not be released until 16 weeks after 24-MAR-2000
    How much do we have to pay and who do we have to kiss to get a freakin update from Oracle? As the author of this comment has a support contract, they will know that you do not automatically get updates for products for which you hold licences. You merely need to order the latest version of the CD. Your support Account Manager will be able to advise you how to do this.
    Once again, please be assured that we value your time, effort and feedback and that we do watch this forum with great interest.
    I hope you found this information useful.
    Jason Pepper
    Senior Product Manager
    Oracle Enterprise Internet Tools

    As an update on the OTN performance problem I talked about earlier, I got some info from Global Ops
    Customers are trying to download software from ftp.oracle.com, a server managed by the datacenter. The server is actually 2 servers (mirrored), with 1,400 connections (700 per machine). Bottom line is that ftp.oracle.com doesn't have enough connections to support the number of users trying to download Oracle products each day. Approval has been received for a dedicated OC3 pipe to the ftp server; it's believed this will boost the current capacity to 4-5 times what's there today.
    Other improvement measures are being investigated.
    Whilst this is being resolved, please consider ordering the CD which is free. I have just tested this and it worked for me ;)
    Jason Pepper
    Oracle Enterprise Internet Tools

  • EWA Alert 'rating not defined' and 'download problem' (last week it's fine)

    Hi Friends,
    Please help me with this Alert.
    We have a weekly schedule of EWA report. Lat week the report was fine (green).
    This week it's been grayed out. the erro is Rating not defined and download problem.
    I have run the EWA report and it generated well.
    As per the EWA aler recomendation, i have run the sysprep check (sdcc) in target system. as per the report ihave checked the patches, they seems to be ok.However till last week the report was fine(Green).
    I have checked the RFC connections etc.
    Please check the following error message and help me soon. Since this is a production system.
    Regards
    srini

    hi srini,
    r there any upgrades of patches as now i am experiencing the same problem to my qty and dev servers where i have scheduled ewa reps.
    it says dwnld problem... but i assume the recent cvhanges to our servers patch levels has some thing to do with this..as that is the only changewe had perfromed...i would keep u informed once i check back to this issue.
    let me know if u find any,
    Br,
    Sri
    Award points for helpful answwers

  • Download Problems with K8N Neo4 Platinum Nvidia Ethernet Controller

    Just to ask if there is some basic setup for Nvidia network drivers in Windows or in BIOS since I'm having download errors with a DSL connection when i use the Nvidia networking controller, not depending from  the OS I'm booting (WinXP Pro SP2 or  WinXP pro 64). When I download using the Marvell Yukon controller everything  works fine in both operating systems. Additional specs:
    K8N Neo 4 Platinum (latest MSI Nforce4 drivers)
    Athlon 64 X2 4200+
    2GB Transcend RAM
    EVGA 6600 GT 128MB PCI-E
    Samsung Spinpoint 200GB SATA (Win XP Pro + SP2)
    Samsung Spinpoint 200GB SATA (Win XP Pro 64)
    Samsung TS-H522U DVD-RW
    Seventeam ST-550EAG  3.3@30A  5.0@30A  12V1 & 12V2 @ 18A each

    Quote from: Indigian on 07-November-05, 00:23:35
    Open up the nvidia firewall.
    Click on 'Active Armour'
    Click on 'Application'
    change the setting from 'offloadable' to 'notoffloadable'
    This solves the download problem.
    Indigian,  you are The Man!!!!!
    That solved it !!! Thank you very much!

  • Download problems with Oracle 9i

    So that we may better diagnose DOWNLOAD problems, please provide the following information.
    - Server name : http://download-east.oracle.com
    - Filename : 92010NT_Disk1.zip, 92010NT_Disk2.zip, 92010NT_Disk3.zip
    - Date/Time : 15 Aug 2002
    - Browser + Version : IE 5.x, Netscape 4
    - O/S + Version : MS Windows 98/2000
    - Error Msg
    I have been trying to download Oracle 9i for the past three weeks. Every time I try to download the above mentioned files the file Login.jsp gets copied. I've tried using both GetRight and GoZilla!
    Could someone please advise me what to do. Any help would be appreciated.

    I recently downloaded Oracle9i personal edition, it took me more than 7 hours, and the downloaded zip file is A91514-01.zip. You need to check how reliable is your internet connection. regards. winston

  • Firefox downloads "failed". Have reset FF, been through "downloading problems" trouble doc, and uninstalled/reinstalled FF w/o luck. Safari is able to download.

    Recently I am unable to download anything in FF. It briefly acts as if downloading, but the file is corrupted and the next to the file in the DL manager it just says "Failed".
    I tried Resetting FF. No luck.
    Then I tried all the steps in the "downloading problems" support doc. No luck.
    I tried with all add-ons disabled. No luck.
    In desperation, I searched for "Firefox" and moved two folders called Firefox, the application, and a .plist file to the trash (still there) and redownloaded Firefox and reinstalled. No luck.
    If I click on a .pdf it will be be viewable, but it won't download. It's not just .pdfs that fail, it is any file I try and download.

    I have the same problem and I also tried a lot of troubleshooting advices without any success.
    The problem seems to be with OS X Parental Control turned on and using a other account than the one of the admin.
    The user sl-nw found a short-term solutions (changing back to version 31, working like a charm or turning off Parental Control), yet a long-term solution is needed:
    https://support.mozilla.org/en-US/questions/1018279
    Perhaps Firefox should add a bug fix to their next update.

  • JDeveloper 3.0 Download Problem

    I'm unable to download the first file segment of JDeveloper 3.0
    Netscape tells me "... is unable to find the file or directory
    named /pub/www/otn/jdeveloper/jdev30split/jdev.30a.exe". It
    looks like there's an extra dot in the file name. FYI: I've
    been able to download all the other file segments. Thanks!
    null

    The download problem with the first file has been fixed on OTN.
    Laura
    Jim Tabbut (guest) wrote:
    : adrian martin (guest) wrote:
    : : Jim Tabbut (guest) wrote:
    : : : I'm unable to download the first file segment of JDeveloper
    : 3.0
    : : : Netscape tells me "... is unable to find the file or
    : directory
    : : : named /pub/www/otn/jdeveloper/jdev30split/jdev.30a.exe".
    It
    : : : looks like there's an extra dot in the file name. FYI:
    I've
    : : : been able to download all the other file segments. Thanks!
    : : Jim,
    : : I suggest you ftp to the site ftp.oracle.com. Navigate to
    : : pub/www/otn/jdeveloper/jdev30split/
    : : There you will see all the downloadable exe files. Pick the
    : : first one (jdev30a.exe) and download it.
    : : The download time is very slow - not sure why - could be my
    : LAN.
    : : Regards,
    : : Adrian
    : Got it, thanks!
    null

  • Oracle9iAS Release 2 download problems

    So that we may better diagnose DOWNLOAD problems, please provide the following information.
    - Server name
    - Filename
    - Date/Time
    - Browser + Version
    - O/S + Version
    - Error Msg
    Hello,
    I have successfully downloaded Disk1,Disk3 and Disk4 of the Oracle9iAS Release 2 for Linux. When trying to download Disk2
    I am getting the following error:
    Server Error
    The following error occurred:
    The ICAP server reset the connection while reading the response. The ICAP server has a problem. Contact your system administrator.
    Please contact the administrator.
    Any help geratly appreciated.
    Zoran Sabljo

    Slight confusion, methinks.
    9iDS is available now for XP/W2K.
    9iAS is still a few weeks away from release.
    There have been previous threads on OTN on this very subject.

  • Download problem for my mac

    download problem for my mac it keep on say safari is open when its not

    Eric Cosby which Adobe software or service are you referring too?  Have you tried utilizing the Activity Monitor to verify that Safari is closed?

  • IOS 5 - Download-Problem - Zeitüberschreitung der Netzwerkverbindung - Was ist das ? Kann jemand helfen ? Was genau muss ich tun ?????

    iOS - Download-Problem beim Update-Laden !!
    > Ich erhalte folgende Fehlermeldung : Beim Download der Software für das iPhone ist ein Fehler aufgetreten. Bei der Netzwerkverbindung ist eine Zeitüberschreitung aufgetreten.
    Überprüfen Sie, ob Ihre Netwerkeinstellungen korrekt sind und Ihre Netzwerkverbindung aktiv ist oder versuchen Sie es später nochmals
    > Alles gecheckt und x-mal versucht - Kein Erfolg
    Kann mir jemand da draussen in der grossen, weiten Welt weiterhelfen ??????
    Danke bestens - Roethls

    Hallo,
    "Eingabe der Seriennummer zusätzlich eine "alte Seriennummer"" hört sich nach einer Updateversion. Falls keine Vorversion vorhanden ist, ist diese leider "Wertlos". Also nochmal genau auf die Box oder den Bestellvorgang schauen.
    "Es kommt die Meldung: "Beim Extrahieren einiger Dateien ist ein Problem aufgetreten". Passiert manchmal beim Auspacken der Installationsdateien. Einfach mal 7-zip installieren und das Installationsprogramm auspacken. Da drinn gibt es einen 32bit und 64bit Ordner mit den eigendlichen Setups. Das korrekte Setup starten.
    Die aktuell LR Version kann hier Adobe - Lightroom : For Windows : Adobe Photoshop Lightroom 5.7.1 heruntergeladen werden. Eine älteren LR5 Version muss vorher nicht installiert werden. Allerdings löst auch das nicht das Problem mit der "Update"-Lizenennummer.

Maybe you are looking for

  • Lost my laptop, how do I transfer all media from phone to new pc?

    Lost my laptop, how do I transfer all media from phone to new pc? cheers

  • How to use a non cumulative key figure in a multi planning area

    Hi I'm new to bps, my problem is I need to read the last stock quantity and value at plant and material level to do further calculations in a fox formula, so i made a planning area for the cube 0rt_c36 and another for my tc cube where the results sho

  • The TCP/IP connection to the host 127.0.0.1 , port 1433 has failed

    hi all, i am using SQL2005 server as my database server. i am trying to connect this server in java (i mean using JDBC). i am using windows authentication to connect my sqlserver. i have the url connection like this DriverManager.getConnection("jdbc:

  • Solid Yellow Light requiring reset

    I have an AirPort Extreme base station with two iMacs as my basic wireless home network. I have a TiVo Series 2 unit also on the network. My DSL modem is attached to the AirPort Extreme base station and I have a rock solid connection to the Internet

  • AutoUpdate/Ati Catalyst Broken!

    AutoUpdate/Ati Catalyst Broken!? When using AutoUpdate here are some things I had to do to get it working: ) installed standard Creative drivers for my X-FI Titanium 2.7.007 it worked 2)? installed ATI Catalyst 9.0 it stopped working. 3) by mistake I