Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how would i do the following

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a page which a user can select items to download. Once the user clicks select an action determines which items are selected and then zips the items and includes the files in the response. The problem however is that I get a

IllegalStateException: getOutputStream() has already been called for this response

this is part of the code im my action

response.setContentType("application/zip");
response.addHeader("Content-Disposition", "Attachment; Filename=" + packager.getTonePakName());
ServletOutputStream outputStream = response.getOutputStream();

while ((lengthToRead = tonePakInput.available()) > 0)
{
data = new byte[lengthToRead];
outputStream.write(data);
}
tonePakInput.close();
request.setAttribute("selNew", new);
request.setAttribute("selOld", oldt);
return mapping.findForward("mytones");

Someone suggested using a meta tag, but im not sure how to quite use it. I would like to always remain on the same page. Select the items to download refresh the page through the action and then use the meta tag to pass the zip files. I have seen the above on other sites but im not sure how to do it.

Thank you all for your time
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right now all of this is happening in a action class

like i mentioned earlier someone suggested using a meta tag like

<meta http-equiv="Refresh" content="1; URL=http://members.optusnet.com.au/m.tabbara/RubberDockey.dmg">

would some like this work for what i need
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like my wife always tells me, "You forgot to flush."
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry were exactly would i flush the buffer and would that really solve the problem?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before the return statement. And then you could probably return null and it wouldn't matter, as your response is the opening of a file.
 
Fire me boy! Cool, soothing, shameless self promotion:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic