【发布时间】:2014-07-17 20:08:18
【问题描述】:
所以我正在 Tomcat 7 上使用 JSP 开发 Web 应用程序。我需要能够从保存为我计算机上共享文件夹驱动器的几个 Tomcat 服务器中检索日志文件,然后能够使用正则表达式对其进行解析表达。但是,无论如何都可以检索文件而无需使用表单手动上传。
我试过了
public void init() throws ServletException {
// Define base path somehow. You can define it as init-param of the servlet.
this.filePath = "/Users/oakesjo/Documents/LogViewerTools";
// In a Windows environment with the Application server running on the
// c: volume, the above path is exactly the same as "c:\files".
// In UNIX, it is just straightforward "/files".
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException {
// Get requested file by path info.
String requestedFile = request.getPathInfo();
...}
但是,this.filePath 只会让我访问 C: 驱动器(本地计算机)上的文件,而不是其他网络驱动器。有没有其他方法来配置这个?另外:是否存在仅将文件自动存储到字符串的选项?
【问题讨论】:
标签: java regex apache jsp tomcat