Archive for October, 2005

You are currently browsing the archives of Enabling Technology .

Linux Java Remote call

10月21日

 

echo "###########################################" date echo "hi this is called from the Web, so you could call from any where in the world!" date echo $PATH echo "end of demo" echo "thank you !" mozilla-firefox sleep 2
===========================
package com.kbhy.micas;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Commander {
    public static void main(String[] args) {
        System.out.println(runCommand());
    }
    public static String runCommand() {
        StringBuffer sbf = new StringBuffer();
        try {
            System.out.println("##########################");
            String [] a = {"/bin/sh","-c","/home/micas/mywork/src/tt.cmd"};
            Process p = Runtime.getRuntime().exec(
                a);
            InputStream i = p.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(i));
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
                sbf.append(line + "\r\n<br>");
            }
        } catch (Exception ex) {
            sbf.append(ex.toString());
        }
        System.out.println(sbf);
        System.out.println("###########################");
        return sbf.toString();
    }
}
=======================
<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%
try {
            out.println(com.kbhy.micas.Commander.runCommand());
            } catch (Exception ex) {
                out.println(ex);
            }
        %>
</body>
</html>

Posted by micas on Oct 21st 2005 | Filed in Enabling-tech | Comments (0)

remote debug JSP

今天终于成功地使用了IntelliJ 5.0的调试jsp的功能,以后再也不用在jsp页面写输出语句来看结果了。

步骤如下:打开远程的tomcat以调试模式打开:catalina.bat jpda start 注意已经设置好环境变量:

   JPDA_ADDRESS=5050
                JPDA_TRANSPORT=dt_socket

然后使用IntelliJ的Run->Config->tomcat server 设置好tomcat 以及调试的端口。

不要使用remote,这个不能调试jsp.

庆祝。

Posted by micas on Oct 13th 2005 | Filed in J2EE | Comments (0)