How to display InputSream dynamically on a JSP page?
posted 5 years ago
What I want to do is to display the console output in the JSP. I am getting the Stream to be displayed dynamically. The objective is to execute some commonly used shell scripts on remote servers and display the console which gets displayed when one manually logs on to the server and runs those scripts. I am stuck with the displaying part of it. Remote scripts are getting executed well and I am able to print the console output to local console, but I want to display it dynamically in the browser page. Here’s a code snippet which executes the shell script and gives the required stream.
Now we have number of servers where different scripts are to be executed time and again. So displaying different server’s console in different tabs. Number of servers are pre-configured in an xml.
I am displaying different tabs as follows:
Now what I want to do is to have 3 buttons on each tab. And on clicking on each of those buttons send a AJAX call which will execute a script on that particular host and display the console output in a div next to these buttons. Also want to have only one div which will be common to all the three buttons and display console in that one div itself. One div per tab/host.
What I have done is to write the console output to a log file and read the log file in a custom tag as follows:
The problem here is that I am not able to close the stream as I never know when to stop reading the log file. Also div isn’t closed and will not work for more than one tabs. Can someone please suggest a way to get the console printed properly for all tabs?