#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0

    Program execution within JSP


    Hi,

    I'm a bit of a JSP newbie so please bear with me.

    Is it possible to invoke an external program from within a JSP page and include its output on the generated page.

    e.g. I want to run a program which generates the log statistics of my FTP server and outputs them in HTML format.

    I am running tomcat on a Redhat 8 box.

    Thanks

    Woz
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Yes. You can do virtually anything you would normally do in a server side program in a jsp.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0
    Thanks for the reply. However, could you expand a little bit. As an example, how would I execute, say, the unix ls command and integrate the directory listing into the page??

    Thanks

    Warren
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Ok, you were relatively vague, so I was also. I did not know if you were talking about running another java program for instance.

    Anyway, you can run native programs by using the Runtime.exec() method. This method returns a Process object that allows you to get output. It basically allows you to run anything as if you were typing it in at the command line. However, there are some gotcha's invloved. Here is a short article that may help.

    http://www.mountainstorm.com/publications/javazine.html
    Last edited by Nemi; May 5th, 2003 at 08:40 AM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    3
    Rep Power
    0
    Excellent. That is just what I need. Thankyou.

IMN logo majestic logo threadwatch logo seochat tools logo