Re: Directory Creation in Servlet Question
On 5/6/05, Joe Hertz [EMAIL PROTECTED] wrote: In Windows that's what it means too, but this isn't Windows or Linux...it's a JVM. Since it wasn't obvious from the code (MessageResources used in pathnames), let me put it another way. The code tries to create a directory /images/userid. The Servlet is apparently limited in the filepath it gets to work with. I'd expect that. In Windows, Tomcat executes it and it goes to C:\tomcat4\images\userid In my Suze install, Tomcat the analogous directory /opt/tomcat4/webapps/images I didn't check to see if it's *different* because in the code it won't be. It's the same identifier working off of root. Windows Tomcat puts it under it's webapps tree. I'm expecting Suze to do the same. I have a hard time imagining that Tomcat gets a different view of its root file system depending on which OS I runs on. It really ruins the concept of platform independence for this sort of thing. -Joe you tried to debug it. You can check what is the path before the directory is created. In Linux / means the root directory and since the path name begins with File.separator(/), the file is created with reference to /. For eg. if filePath is /anto. Then if Tomcat have write permission to root directory the directory will be created. -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] You should read the API spec of java.io.File. http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html If you want to get the absolute path of the application directory use ServletContext.getRealPath(/); and pass this to the file creating code. -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Directory Creation in Servlet Question
If you want to get the absolute path of the application directory use ServletContext.getRealPath(/); and pass this to the file creating code. Yes, I could, but this again didn't explain the behavior which turned out to be: Try to create \images in a servlet running under Windows Tomcat, it becomes C:\tomcat4\webapps\images. Try to create /images in a servlet running under Suze and it becomes /images. I would expect to have to be /images in Windows too, except it didn't work that way. Okay, so Tomcat effects a chroot somehow. But I then expected it to continue under Suze and was dissapointed. I strongly suspect that what you describe will not work under Windows Tomcat even though it should - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Directory Creation in Servlet Question
If you want to get the absolute path of the application directory use ServletContext.getRealPath(/); and pass this to the file creating code. Yes, I could, but this again didn't explain the behavior which turned out to be: Try to create \images in a servlet running under Windows Tomcat, it becomes C:\tomcat4\webapps\images. Try to create /images in a servlet running under Suze and it becomes /images. I would expect to have to be /images in Windows too, except it didn't work that way. Okay, so Tomcat effects a chroot somehow. But I then expected it to continue under Suze and was dissapointed. I strongly suspect that what you describe will not work under Windows Tomcat even though it should - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Directory Creation in Servlet Question
On 5/6/05, Joe Hertz [EMAIL PROTECTED] wrote: I have a Struts Servlet that executes the code snippet below to create a directory. Under Windows, this works great, the directory showing up under C:\TOMCAT4\WEBAPPS\ Under Suze Linux, it doesn't get created, and it's not a permission problem. At least not under the webapps directory. The Tomcat user can definitely create a directory there (I've su'd to him and done it). What should I be looking at next? String filePath = File.separator + userId; File dirs = new File(File.separator + rs.getMessage(imageFilePath) + filePath); dirs = new File(File.separator + rs.getMessage(imageFilePath) + filePath); if (!dirs.exists()) { dirs.mkdirs(); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] you tried to debug it. You can check what is the path before the directory is created. In Linux / means the root directory and since the path name begins with File.separator(/), the file is created with reference to /. For eg. if filePath is /anto. Then if Tomcat have write permission to root directory the directory will be created. -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Directory Creation in Servlet Question
In Windows that's what it means too, but this isn't Windows or Linux...it's a JVM. Since it wasn't obvious from the code (MessageResources used in pathnames), let me put it another way. The code tries to create a directory /images/userid. The Servlet is apparently limited in the filepath it gets to work with. I'd expect that. In Windows, Tomcat executes it and it goes to C:\tomcat4\images\userid In my Suze install, Tomcat the analogous directory /opt/tomcat4/webapps/images I didn't check to see if it's *different* because in the code it won't be. It's the same identifier working off of root. Windows Tomcat puts it under it's webapps tree. I'm expecting Suze to do the same. I have a hard time imagining that Tomcat gets a different view of its root file system depending on which OS I runs on. It really ruins the concept of platform independence for this sort of thing. -Joe you tried to debug it. You can check what is the path before the directory is created. In Linux / means the root directory and since the path name begins with File.separator(/), the file is created with reference to /. For eg. if filePath is /anto. Then if Tomcat have write permission to root directory the directory will be created. -- rgds Anto Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]