I have an action class with a method serverstate where I am parsing few server details and weblogic command to get the current status of weblogic servers.The code below gives the required output in eclipse console and not on the GUI could someone please help regarding this, I want to display the output on the GUI(JSP) page coded by me by using sessions.
public void serverstate(HttpServletRequest request,HttpServletResponse response) throws IOException, Exception
{
String appname;
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
String selapp = " ";
System.out.println("enter appname:");
selapp = dataIn.readLine();
System.out.println("selected app is:" + selapp );
{
try
{
File apps = new File("/WEB-INF/appdetails.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(apps);
doc.getDocumentElement().normalize();
System.out.println("server status of " + selapp);
NodeList nodes = doc.getElementsByTagName("app");
System.out.println("==========================");
for (int i = 0; i < nodes.getLength(); i++)
{
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE);
{
Element element = (Element) node;
appname = getValue("name", element);
System.out.println(appname);
String user = getValue("uname", element);
System.out.println(user);
String server = getValue("server", element);
System.out.println(server);
String command = getValue("cmd", element);
System.out.println(command);
String passwd = getValue("passwd",element);
System.out.println(passwd);
String cmd= getValue("cmd",element);
System.out.println(cmd);
String port=getValue("port",element);
String clu=getValue("cluster",element);
String admin=getValue("admstate",element);
System.out.println(admin);
if (selapp.equalsIgnoreCase(appname))
{
try {
Runtime rt = Runtime.getRuntime();
//Process pr = rt.exec("cmd /c dir");
{
Process pr = rt.exec(""+ command +" && "+ admin +" && java weblogic.Admin -url "+ server +":"+ port +" -username "+ user +" -password "+ passwd +" CLUSTERSTATE -clusterName "+ clu +"");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
System.out.println(line);
// int exitVal = pr.waitFor();
//System.out.println("Exited with error code "+exitVal);
}}}finally{
}}else {
System.out.println("no app selected");
}}}}catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}}
RequestDispatcher dispatcher = request.getRequestDispatcher("status.jsp");
dispatcher.forward(request,response);
}
this method gives me the output in eclipse console and I want to display the same output in the Jsp page created by me using sessions.please help