3 Replies Latest reply: Aug 26, 2007 11:57 PM by 807605 RSS

    Running class files on a server.

    807605
      Hi Guys,
      I have a class file (works fine) which takes data from a data base table and writes it out to an XML file. I tested it on my local machine using the tomcat server and it runs just fine.
      Next thing I want to do is run it on my server which is Java enabled, I am currently hosting some servlets on it.
      What is the best way to run it automatically. Using cron jobs?
      If so is it better to call a batch file to run the java command on the class file or would it be better to run a html file to call the class file from a form.
      I know with other languages it is common to put scripts in the cgi-bin; should I be taking this folder into account when using java.

      Plus if any one knows how could I write the xml files out so that they could only be ftp'ed by someone with a user name and password permission.
      All the best,
      Anthony from http://touchscreens.ie .

      P.S. the code I used to create the original file is on http://rustemsoft.com/JSPsample.htm

      Message was edited by:
      Anthony@dearg.net
        • 1. Re: Running class files on a server.
          800345
          Hi Guys,
          I have a class file (works fine) which takes data
          from a data base table and writes it out to an XML
          file. I tested it on my local machine using the
          tomcat server and it runs just fine.
          ext thing I want to do is run it on my server which
          is Java enabled, I am currently hosting some servlets
          on it.
          What is the best way to run it automatically. Using
          cron jobs?
          Is the idea to have the XML document generated at regular intervals? Then yes, cron jobs work nicely. Is the idea to have the user or some action on the server trigger the work to be done? Then the cron job wouldn't be best.
          If so is it better to call a batch file to run the
          java command on the class file or would it be better
          to run a html file to call the class file from a
          form.
          Run from the command line if you can. Why complicate the issue with HTML requests, forms and the like?
          I know with other languages it is common to put
          scripts in the cgi-bin; should I be taking this
          folder into account when using java.
          Nope.

          >
          Plus if any one knows how could I write the xml files
          out so that they could only be ftp'ed by someone with
          a user name and password permission.
          Save the XML file to a location accessible by your FTP server. Then password protect the directory inside you FTP server.

          All the best,
          Anthony from http://touchscreens.ie .

          P.S. the code I used to create the original file is
          on http://rustemsoft.com/JSPsample.htm

          Message was edited by:
          Anthony@dearg.net
          • 2. Re: Running class files on a server.
            jwenting
            if something needs to run at set times or intervals, a cron job is an excellent choice on a Unix machine.
            • 3. Re: Running class files on a server.
              807605
              If you're using an application server, it's worth checking its documentation to see if it provides a service to execute arbitrary classes at scheduled times and/or regular intervals.

              The advantage of that over a cron job is that it keeps your application code together (assuming that this code is part of the application that you're running under the server). That way, a future maintainer is less likely to be surprised.

              This is a minor point, however.