title: Spring Boot - redirecting to url and provide file Download
body: <p>Is there any way in Spring to provide a File download and a view?
  I want to give the user an automatic download and inform the user with a new html page.</p>
  
  <pre><code> @RequestMapping(value = "/abgeschlossen/{bildcodes}")
   @ResponseBody
    public byte[]  download(@PathVariable List&lt;String&gt; bildcodes,
    HttpServletRequest request, HttpServletResponse response) throws 
  IOException, ServletException {
  
      response.setContentType("application/zip");
      response.setStatus(HttpServletResponse.SC_OK);
      response.addHeader("Content-Disposition", "attachment; filename=\"test.zip\"");
  
      //creating byteArray stream, make it bufforable and passing this buffor to ZipOutputStream
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
      ZipOutputStream zipOutputStream = new ZipOutputStream(bufferedOutputStream);
  
  
      //packing files
      for (int i = 0;i&lt;bildcodes.size();i++){
          Bild a = bildDao.findBildByCode(bildcodes.get(i));
          if (a!=null) {
              //new zip entry and copying inputstream with file to zipOutputStream, after all closing streams
              zipOutputStream.putNextEntry(new ZipEntry("Bild" + i + ".jpg"));
              ByteArrayInputStream fileInputStream = new ByteArrayInputStream(a.getDatei());
  
              IOUtils.copy(fileInputStream, zipOutputStream);
  
              fileInputStream.close();
              zipOutputStream.closeEntry();
          }
      }
  
      if (zipOutputStream != null) {
          zipOutputStream.finish();
          zipOutputStream.flush();
          IOUtils.closeQuietly(zipOutputStream);
      }
  
      IOUtils.closeQuietly(bufferedOutputStream);
      IOUtils.closeQuietly(byteArrayOutputStream);
      //RequestDispatcher rd=request.getRequestDispatcher("/abgeschlossen/fertig");
      //rd.forward(request, response);//method may be include or forward
      return byteArrayOutputStream.toByteArray();
  }
  </code></pre>
  
  <p>I simultaneously need to return my view </p>
  
  <pre><code>return "finished.html";
  </code></pre>
  
  <p>I found some solutions with the HTMLresponse but there I have problems with to many redirects. </p>
  
  <p>Hope someone can help me. </p>