-2
我通常使用PHP,但需要使用我正在與之交互的服務器來設置此JSP。這裏是我嘗試代碼:我可以使用JSP在我的服務器上移動文件嗎?
<%
String filename = request.getParameter("file");
filename = "C:\Tomcat 5.5\webapps\myapp\\" + filename;
out.print(filename);
ActiveXObject theObject = new ActiveXObject("Scripting.FileSystemObject");
File theFile = new theObject.GetFile(filename);
theFile.Move("C:\Tomcat 5.5\webapps\myapp\processed\\");
%>
的目標是在發送請求到http://www.thewebsite.com/myfile.jsp?file=x.txt
和JSP文件中應採取x.txt
,並將其移動到processed
目錄。
當我調用這個JSP文件時,我得到一個錯誤,說ActiveXObject cannot be resolved to a type
...所以,我想我不能這樣做。
是否可以使用JSP來移動文件?
JSP表示** Java **服務器頁面。您應該閱讀** Java ** api引用,而不是盲目地嘗試使用顯然只能在Windows上存在的對象。 Java是一種多平臺語言。 http://download.oracle.com/javase/6/docs/api/。另外,閱讀這篇文章:http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files –