Program execution within JSP
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.
Yes. You can do virtually anything you would normally do in a server side program in a jsp.
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??
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.
Last edited by Nemi; May 5th, 2003 at 09:40 AM.
Excellent. That is just what I need. Thankyou.