4 Replies Latest reply on Jul 30, 2003 5:10 AM by blackers

    Modifying Files

    blackers

      It is my understanding that you are not supposed to deal with File i/o in EJB's. I have an applet that needs to modify the contents of a file on the server. What is the best way to go about this? In particular I need to copy the contents of one file to a new location when a function has been called in my EJB.

      Any thoughts would be appreciated.

        • 1. Re: Modifying Files
          jonlee

          You could build an MBean that performs the file I/O and the EJB could call the MBean or you could build an MBean that binds a writer object to the JNDI and the EJB can lookup an invoke that. That should satisfy the abstraction of EJBs from the file I/O layer.

          Another way is to have your servlet talk HTTP and build a web application layer that on-sends the request to the EJB and at the end of it, if successful, write something to file - also saves the servlet from carrying around the JBoss client library.

          Depends on your requirements, time frame, etc.

          Obviously quite a few ways to do things but those are a couple of suggestions.

          • 2. Re: Modifying Files
            blackers

            Thanks. I think I will look into the MBean idea.

            • 3. Re: Modifying Files
              jonlee

              BTW, I meant applet not servlet. It was getting late at night.

              • 4. Re: Modifying Files
                blackers

                Cool, thanks