English 中文(简体)
如何利用java方案在编目网络服务器中创建一个夹子?
原标题:how to create a folder in tomcat webserver using java program?

i 想知道如何在java的网络服务器(tomcat 7.0)中制造一个倍数。

iam最近启动了一个项目。 在该项目中,需要从客户机器上将档案上载到服务器。 每个客户都有自己的双倍服务器,并将档案上载。

在每个用户夹中,我们有两多份jsp文档。 当用户要求服务器用该文档显示其上载数据时(例如:处理:编号/使用/索引.jsp)。

是可能的?

please,guide me to solve this problem. thanks.

最佳回答

至于你的具体问题,与 Java的正常申请一样。

File root = new File("/path/to/all/uploads");
File newfolder = new File(root, "/userid");
newfolder.mkdir();
// ...

As to your idea with those copypasted JSP files over all folders, don t do that. Just have a single servlet which is mapped on for example /files/* and reads the folder specific to the currently logged-in user and finally forwards to the JSP to present the results. Or if your intent is really to make the uploads public to everyone so that each user can see each other s uploads, then supply the desired user ID as parameter or pathinfo in the request URL like so http://localhost:8080/context/files/userid.

请注意,你应当把档案存放在经扩大的WAR文件夹中,或者每当你重新调配网上申请时,就会丢失。 在Tomcat s/webapps外的固定道路上储存。

问题回答

http://docs.oracle.com JDK7的新文件I/O机制。 See also the Java I/O Tutorial 。ache Commons IO

我们来到这里。

try {
  File f = new File("file/path/name/.ext");
  if(!f.isDirectory()) {
     boolean success = (new File(f)).mkdirs();
  }
  if(success) {
     System.out.println("Success")
  }
} catch(Exception e) {}

这就是说。 我希望这在功能上能够做到。 Ciao





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签