Re: [JSP ] 請教有關Runtime.exec錯誤的問題
※ 引述《smallma009 (我要努力認真!)》之銘言:
: 第三次try利用網頁執行遠端的bat檔(絕對路徑)
: 但是把那些檔案放在server端時
: 再用網頁方式去執行就會跳
: type Exception report
: message
: description The server encountered an internal error () that prevented
: it from fulfilling this request.
: exception
: org.apache.jasper.JasperException: Exception in JSP: /jsp_test/a/1.jsp:13
: 10: <%
: 11: Runtime o_run_notepad = Runtime.getRuntime();
: 12:
: 13: o_run_notepad.exec("http://xxx.xxx.xxx.xxx/jsp_test/a/1.bat");
: 14:
: 15: %>
: 16:
: Stacktrace:
: org.apache.jasper.servlet.JspServletWrapper.handleJspException(
: JspServletWrapper.java:451)
: org.apache.jasper.servlet.JspServletWrapper.service(
: JspServletWrapper.java:361)
: org.apache.jasper.servlet.JspServlet.serviceJspFile(
: JspServlet.java:329)
: org.apache.jasper.servlet.JspServlet.service(
: JspServlet.java:265)
: javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
我所謂的絕對路徑是指 1.bat 檔在 server 檔案系統裡的完整路徑,比如說 1.bat
是放在 server 那台 Windows C 槽的跟目錄下,那麼絕對路徑就是 "c:\\1.bat"。
(1.bat 不需要讓外部可以從 http server 下載)
1.bat 裡調用的執行檔也必須要在 server 上,並且 1.bat 裡給定的絕對路徑(同樣
不是指什麼 http://abc.def.com.tw/xyz/abc.exe 這樣的 URL)要正確。
另外,你要了解到 JSP 是 server site 程式,也就是說在上述作法下,一旦有
user 拜訪你的 JSP/servlet 產生的頁面,JSP 所在的 web server 會執行 1.bat
的指令。1.bat 如果會 download 任何東西,是 download 到 JSP 所在的 web
server 而不是 user 的電腦裡。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.173.128.243
※ 編輯: sbrhsieh 來自: 218.173.128.243 (03/03 20:23)
推
03/04 18:02, , 1F
03/04 18:02, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):