how to send a file and redirection in one request?

I have a servlet that send file to client . Is it possible to add a redirect in order to start the download and redirect the user to anoteher html page ? This is my code :

  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            try {
                System.out.println("debut transfert fichier a " + request.getRemoteUser() + "/" + request.getRemoteAddr());

                // ServletContext ctx = getServletContext();
                File jnlp = new File(PATH);
                InputStream is = new FileInputStream(jnlp);

                int read = 0;
                byte[] bytes = new byte[BYTES_DOWNLOAD];
                OutputStream os = response.getOutputStream();

                while ((read = != -1) {
                    os.write(bytes, 0, read);
                 // not workinggetServletContext().getRequestDispatcher("/merci.html").forward(request, response);

                HttpSession session = request.getSession();

            } catch (Exception ex) {
                System.out.println("Erreur inconnu lors transfert :" + ex);



A better way round for this is to send the user to the summary/thank you page (passing it a URL to the download) and have that "redirect" the browser to the actual download URL.

The user should stay on the second page as the browser will recognise that the "redirect" is to a download rather than a new page.

Need Your Help

Fire Javascript during CSS/JS animation (vanilla JS)

javascript html css css3

Edit: this is an example of what I'm trying to do:

How big can a Sourcesafe DB be before "problems" arise?

performance version-control visual-sourcesafe limits

We use SourceSafe 6.0d and have a DB that is about 1.6GB. We haven't had any problems yet, and there is no plan to change source control programs right now, but how big can the SourceSafe database...