How does the SourceForge download page work?

Answers to other questions indicated that the SourceForge download page worked by adding a hidden <iframe>. This is not so ...

How is the current version of the download page implemented? I would like to build something like this because I find the SF solution quite elegant.

Well, more precisely ... True, the original "question" was too vague.

If you go to http://sourceforge.net/projects/beankeeper/files/beankeeper/2.6.2/beankeeper-2.6.2.tar.gz/download , there is a simple old HTML link to download the file, but there is also automatic download. The delay appears to be about 2 seconds.

Someone asked for my specific use case. I will answer this, knowing that he can be distracted from the OP to a certain extent. Very simplified:

  • more or less traditional Java EE application with two servlets
  • Servlet Manager, which acts as an entry point for the user interface controller.
  • the "servlet" that transfers the PDF to the browser, it does this using content-disposition = attachment ie the browser displays a save or open dialog
  • print a page with several input fields and a submit button
  • when you click submit
    • the values ​​of the input field should be updated in the user interface model (and, if necessary, the session) → what the servlet manager does
    • need to create a pdf file -> what the Servlet document does

SF, , Servlet ( ). - , SF ? - Servlet.

+3
2

.

SSCCE, 'paste'n'run.

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2222034</title>
        <script>
            window.onload = function() {
                setTimeout(function() {
                    window.location = 'http://download.java.net/maven/1/jstl/jars/jstl-1.2.jar';
                }, 2000); // It "cool" to let user wait 2 more seconds :/
            }
        </script>
    </head>
    <body>
        <p>The download of jstl-1.2.jar will start shortly...</p>
    </body>
</html>

, POST, :

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2222034</title>
        <script>
            window.onload = function() {
                setTimeout(function() {
                    document.getElementById('downloadform').submit()
                }, 2000); // It "cool" to let user wait 2 more seconds :/
            }
        </script>
    </head>
    <body>
        <p>The download of jstl-1.2.jar will start shortly...</p>
        <form id="downloadform" action="http://download.java.net/maven/1/jstl/jars/jstl-1.2.jar"></form>
    </body>
</html>
+8

MHO, SourceForge, CodePlex . Google: , - , . , : , .

+5

Source: https://habr.com/ru/post/1731864/


All Articles