Is this possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry

    Is this possible?

    Firstly sorry for cross posting but not really sure which group this belongs
    in?

    Anyway, I have a webapp that basically consists of 2 screens, search critera
    & results

    I want to be able to provide a way for the user to download a zipped up
    excel file of the results.

    I can quite easily create a excel file using POI & zip it up using
    java.util.zip which creates a zip file on the server. Then add a link to
    this file on the results page which when clicked will produce the standard
    download dialog box & alls well.

    The problem is I have to create the zip file every time the results
    generated & displayed but some users might not want this faclity!

    Is it possible to have a button/link etc... that when clicked create's the
    zip file & produces the download dialog box WITHOUT changing the results
    page?

    Any ideas?

    thanks

    harry


  • Martin Honnen

    #2
    Re: Is this possible?



    Harry wrote:
    [color=blue]
    > Firstly sorry for cross posting but not really sure which group this belongs
    > in?
    >
    > Anyway, I have a webapp that basically consists of 2 screens, search critera
    > & results
    >
    > I want to be able to provide a way for the user to download a zipped up
    > excel file of the results.
    >
    > I can quite easily create a excel file using POI & zip it up using
    > java.util.zip which creates a zip file on the server. Then add a link to
    > this file on the results page which when clicked will produce the standard
    > download dialog box & alls well.
    >
    > The problem is I have to create the zip file every time the results
    > generated & displayed but some users might not want this faclity!
    >
    > Is it possible to have a button/link etc... that when clicked create's the
    > zip file & produces the download dialog box WITHOUT changing the results
    > page?
    >
    > Any ideas?[/color]

    Assuming you are working with Servlets or JSP on the server you need to
    find out how to set a HTTP response header with them and set a headers alike
    Content-Type: application/octet-stream
    Content-disposition: attachement; filename=whatev er.zip
    and then stream the zip to the browser
    --

    Martin Honnen


    Comment

    • Andy Fish

      #3
      Re: Is this possible?

      yes

      simply have the download URL pointing to a servlet (or whatever server side
      technology you are using)

      in the servlet build the zip file, set the content-type to
      application/x-zip-compressed and write out the zip data as the HTTP body.

      note that you with java.util.zip, you can simply open up a zipOutputStream
      on the response's output stream so you don't need to save it to a file at
      all.

      I would also suggest the url ends in .zip as well. Sometimes IE seems to
      look at the file extension of the URL as well as the content type

      Andy

      "Harry" <a@abc.com> wrote in message
      news:WWHub.4671 $nZ5.40432805@n ews-text.cableinet. net...[color=blue]
      > Firstly sorry for cross posting but not really sure which group this[/color]
      belongs[color=blue]
      > in?
      >
      > Anyway, I have a webapp that basically consists of 2 screens, search[/color]
      critera[color=blue]
      > & results
      >
      > I want to be able to provide a way for the user to download a zipped up
      > excel file of the results.
      >
      > I can quite easily create a excel file using POI & zip it up using
      > java.util.zip which creates a zip file on the server. Then add a link to
      > this file on the results page which when clicked will produce the standard
      > download dialog box & alls well.
      >
      > The problem is I have to create the zip file every time the results
      > generated & displayed but some users might not want this faclity!
      >
      > Is it possible to have a button/link etc... that when clicked create's the
      > zip file & produces the download dialog box WITHOUT changing the results
      > page?
      >
      > Any ideas?
      >
      > thanks
      >
      > harry
      >
      >[/color]


      Comment

      Working...