2 Replies Latest reply on Apr 29, 2005 9:03 AM by wimana

    Reading/Writing files with JSP

    wimana

      I?m developing a web application with JSP/Java classes. In short what the program is supposed to do:

      o Read a directory and make a list of them in JSP
      o User can select the ones they need
      o The program (a next JSP) makes 1 file of them

      When I was referring to my files locally (G:/SomeDir/?) it listed the directory. But now I?ve put the files in my .war file and it doesn?t work anymore. If I go the files by myself with my browser they are available.

      Is there something I forgot? Can?t JBoss read/write files in the online directory? Please tell me.

      Regards,

      WIM

      PS: I'm using: JBoss and Eclipse

        • 1. Re: Reading/Writing files with JSP
          milowe

           

          File f = new File(this.getClass().getResource("/yourfileinarchive").getFile())


          • 2. Re: Reading/Writing files with JSP
            wimana

            thank you for posting. i've already found an other solution. the extra dificuly was that i didn't read the files in the JSP itself, but in plain JAVA classes. So i solved the problem by saving the path with :

            Predefinition.getInstance().setUrl(this.getClass().getClassLoader().getResource("files"));


            in a Singleton (Predefinition). In this way all the classes could reach the online files!

            A new happy JBoss user!


            WIM