Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:43:46+00:00 2026-06-12T05:43:46+00:00

I am downloading zip file from web server using Java in my jsf bean.

  • 0

I am downloading zip file from web server using Java in my jsf bean. My code works for JPEG well but not for ZIP. Here is my code.

private void createDownloadFile(final URL downloadUrl, final String mimeType) {
    final FacesContext fc = FacesContext.getCurrentInstance();
    final ExternalContext context = fc.getExternalContext();
    final HttpServletResponse response = (HttpServletResponse) context.getResponse();
    response.setContentType(mimeType);
    response.addHeader("Content-Disposition", "attachment; filename=\"" + downloadUrl + "\"");

    try{
        final OutputStream out = response.getOutputStream();
        IOUtils.copy(downloadUrl.openStream(), out);
        fc.responseComplete();
    }catch (final IOException exc){
      exc.printStackTrace();
    }

}

And this is the error: Empty response, an empty response was recieved from the server. Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:43:47+00:00Added an answer on June 12, 2026 at 5:43 am

    Empty response, an empty response was recieved from the server.

    This message is recognizeable as a XML parsing error in Chrome; the XML parser couldn’t find the requested XML root element. In combination with whatever you’re trying to do, this suggests that you were trying to download the file by JavaScript/Ajax. You cannot do this because JavaScript has due to obvious security reasons no facilities to force a Save As dialog with file content which is been hold in a variable.

    This error message is caused because JSF ajax responses are definied to return a specific XML format, <partial-response><update>, etc. But if the <partial-response> root element is missing in the JSF ajax response, then the browser-specific XML parser will/may show this kind of error.

    You need to download the file by a synchronous request instead. Remove the <f:ajax> or set whatever ajax-toggling attribute of the 3rd party component to false, such as <p:commandButton ajax="false">.

    You don’t need to worry about a page change in the browser, as you’ve set the Content-Disposition: attachment response header, the current page will just remain the same. This problem is in no way specific to Commons IO, by the way.

    See also:

    • How to provide a file download from a JSF backing bean?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ASIHTTPRequest for downloading file from server but its giving error Failed
I'm using python to programatically download a zip file from a web server. Using
I'm trying to download a large .zip file from a web server but I
I'm downloading an entire directory from a web server. It works OK, but I
I'm trying to make android download a zip file from my web server using
I am downloading a zip file from the server when my Silverlight 5 OOB
I am downloading zip files from FTP server using PHP ftp function.I used binary
I am developing c# application, in which i am downloading package(zip file) from server
This is my C# code to download a ZIP file from my server. When
My java program uploads a zip file from my system to FTP server. uploadfile()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.