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

  • SEARCH
  • Home
  • 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 7033479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:04:15+00:00 2026-05-28T01:04:15+00:00

I am trying to return a ZipInputStream containing two different outputstreams as a javax.ws.rs.core.Response

  • 0

I am trying to return a ZipInputStream containing two different outputstreams as a javax.ws.rs.core.Response Stream. When I make a web service call to retrieve the stream, I notice that I get an empty stream back.
I have tried returning a GZipInputStream before, and I have received the expected stream on the client side. Could there be an issue with ZipInputStream that prevents it from being returned properly?
I am using javax 2.4 (servlet-api)
This is how my jax-rs service looks like (I have simplified it a bit):

 @GET
 @Produces({"application/zip", MediaType.APPLICATION_XML})
 public Response getZipFiles(@PathParam("id") final Integer id){

    //Get required resources here
    ByteArrayOutputStream bundledStream = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(bundledStream);
    out.putNextEntry(new ZipEntry("Item A"));
    out.write(outputStream.toByteArray());
    out.closeEntry();

    out.putNextEntry(new ZipEntry("Item B"));
    out.write(defectiveBillOutputStream.toByteArray());
    out.closeEntry();

    out.close();
    bundledStream.close();

    ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bundledStream.toByteArray()));
    return Response.ok(zis).build();
 }

And this is the code that calls the service. I am using axis 1.4:

 HttpMethodBase getBillGroup = null;
 String id = "1234";
 String absoluteUrl = baseURL + BASE_SERVICE_PATH.replace("@id@",id) ;
 getZip = new GetMethod(absoluteUrl);

 HttpClient httpClient =  new HttpClient();
 try {
      httpClient.executeMethod(getZip);
 }
 catch (Exception e) {
      LOGGER.error("Error during retrieval " + e.getMessage());

 }

 InputStream dataToConvert =  getZip.getResponseBodyAsStream();
 ZipInputStream in = new ZipInputStream(dataToConvert);
 ZipEntry itemA = in.getNextEntry();
 //Do more things

On the last line, itemA should have been the first entry added to the stream in the Jax-RS Service, but I am getting a null back. Any idea what might be causing this?

  • 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-05-28T01:04:15+00:00Added an answer on May 28, 2026 at 1:04 am

    In the first block use a ByteArrayInputStream instead of a ZipInputStream, which iterates complex zip entries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to return an html table from a asp.net web service but
Im trying to return a list to a display template containing data from two
I'm trying to return a byte array containing the two's-complement representation of a Bignum
Im trying to return the value that a $ajax call returns, from a function
Hi I am trying to return two variables from a function using the following
I have been trying to return an ARABIC string from a JNI call. The
I'm trying to return a 2d array from call(), I'm having some issues. My
I'm trying to return the first message between two users, whether I sent that
I’m trying return different values to a sub reports parameter based on if it
im trying to return a string value from a method inside my script tag

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.