12 Replies Latest reply on Oct 3, 2007 2:09 AM by aakjpe

    Downloads with

      In a jboss web-app I want the users to be able to download files. The web-app is running on a Sun with Solaris. The files are in /home/filles/
      How do I make a reference in my jsp code, so that the user can use "Save target as..."?

      Kjell P.

        • 1. Re: Downloads with
          peterj
          • 2. Re: Downloads with

            Not exactly. When I used Orion server this was not a problem at all. I could make the refenense in the .jsp file like this: http::/server:1080/kjell/dir/files/result.xls and the user clicked the link, and did "save targer as...".
            But it seems to be more complicated in JBoss.

            • 3. Re: Downloads with
              peterj

              By defining an external directory, you can supply a similar URL to enable downloads. All it takes is a simple configuration change.

              For example, update the 'Host name="localhost"' entry in server.xml as follows:

              <Host name="localhost" ...>
               <Context path="/docs" appBase=""
               docBase="/home/foo/docs"
               debug="99" reloadable="true">
               </Context>
               ...
              </host>


              Then if there is a file /home/foo/docs/design/xxx.odt, you can access it using http://hostname:8080/docs/design/xxx.odt.

              • 4. Re: Downloads with

                Which server.xml file? I find at least 2 files. In ../server/all/deploy/jboss..tomvatt.sar and
                in ../server/default/.....

                Does the JBoss server have to be restarted?

                • 5. Re: Downloads with
                  peterj

                  The server.xml for the configuration you are running. If you don;t run a specific configuration, then the one in 'default'.

                  Yes, you must restart the server.

                  • 6. Re: Downloads with

                    It worked! I can now download files from the exteral directory. One small problem: The files are of type .xls, but when the download dialog box appears the filetype is set to .htm. Anything I can do to change the filetype? The refererence in <a href.. is filename.xls

                    • 7. Re: Downloads with
                      peterj

                      Try adding type="text/xml" to your < a > tag.

                      • 8. Re: Downloads with

                        I have tried several combinations of type, type = "text/xml" "text/xls"
                        "xls", but the save dialog still use the filetype .htm

                        Any hints?

                        • 9. Re: Downloads with

                          Her is how the html code is using view source:

                          <a href="Reports/ActiveUsers.xls" type="text/xml" target=_blank>Rapporten i excel-format ( Save Target As...)

                          If I take a "copy shortcut", the link looks like this:
                          http://padda-o1:1080/PaddaUserAdm/Reports/ActiveUsers.xls

                          But "Save as...", still names the file ActiveUsers.htm.
                          I have to rename the file to ActiveUsers.xls, and can then load the file into excel.



                          • 10. Re: Downloads with
                            peterj

                            Sorry, I read the extension as .xml, not .xls. Try a type of "application/vnd.ms-excel".

                            • 11. Re: Downloads with
                              peterj

                              Another thing to try. Add the following to the long list of mime types in server/xxx/deploy/jboss-web.deploy/conf/web.xml file:

                              <mime-mapping>
                               <extension>xls</extension>
                               <mime-type>application/vnd.ms-excel</mime-type>
                               </mime-mapping>



                              • 12. Re: Downloads with

                                At last it worked! Setting mime type in the web.xml file did it.
                                Thank you very much for the help you have provided.