我可以使用 JSP 在服务器上移动文件吗?
我通常使用 PHP,但需要使用我正在交互的服务器来设置此 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 文件应采用 < code>x.txt 并将其移至 processed
目录。
当我调用这个 JSP 文件时,我收到一条错误,指出 ActiveXObject 无法解析为类型
...所以,我想我不能这样做。
是否可以使用 JSP 移动文件?
I usually work with PHP but need to setup this JSP with a server that I am interacting with. Here is the code I am trying:
<%
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\\");
%>
The goal is to send in a request to http://www.thewebsite.com/myfile.jsp?file=x.txt
and the JSP file should take x.txt
and move it to the processed
directory.
When I call this JSP file I get an error that says ActiveXObject cannot be resolved to a type
... so, I guess that I can't do it this way.
Is it possible to move a file using JSP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这
通常意味着我们需要导入ActiveXObject所在的类。在 JSP 中使用 import 指令导入您需要的包。
希望这有帮助!
This
usually means that we need to import the class where ActiveXObject resides. In JSP use import directive to import the package you need.
Hope this helps!