4 Replies Latest reply on Jul 31, 2007 3:29 AM by wesomon99

    allowing users to access server-created files

    wesomon99

      Hello,
      I have a JBoss server set up for hosting web applications, which is working great. However, I need to allow users to access simple .CSV files that the server creates based on the information they provide. For example, they submit an .XML file, the server does some mumbo jumbo, then they need to be able to download the .CSV file that the server creates. Because of the way applications are deployed, I cannot figure out how to get the file back to them. I can save the .CSV files on the local disk, but the users obviously have no access to to this area.

      Any help is greatly appreciated, I have been struggling with this for a while.

      Server info:
      Apache HTTP server 1.3
      JBoss Application server 4.04
      Sun JVM 1.5.0

        • 1. Re: allowing users to access server-created files
          peterj

          Here is one possibility that comes to mind. Deploy your app exploded (). With the exploded directory, have a directory (for example, csv) and place the generated file there, then generate a web page with a link to the generated file: csv/tempfilename.csv. The user clicks the link to get the file.

          Another possibility is to, within your servlet, change the content type on the ServletResponse to be "text/plain" (not sure if "text/csv" is valid, you could try it) and set the response content to be the csv file contents.

          • 2. Re: allowing users to access server-created files
            wesomon99

            I have deployed my application exploded, which worked fine. However, I can't create a file within the web file structure. The path .../myproject/csv/example.csv does not work, it gives me an error of no such file or directory even though the directory is definitely there.

            • 3. Re: allowing users to access server-created files
              peterj

              Are you using the getRealPath method of the ServletRequest or ServletContext to convert the relative path to a real path? If not, the path is calculated based on the current working directory, which is typically jboss_home/bin.

              • 4. Re: allowing users to access server-created files
                wesomon99

                No I didn't know about that method. Thank you for the tip I will try that tomorrow.