• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to create a folder on the web server from a servlet?  RSS feed

 
Megan Hill
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to create a folder or a file on the web server from a servlet?
If so, How can I do it ?
Thanks
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating a file or directory from a servlet is no different that creating a file from any class.
 
Benny Tang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
 
Benny Tang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It is possible to create the file on the file system of the web server. I think the class java.io.File can achieve this.'
Benny
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Benny T",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right!
Originally posted by Benny T:
Hi,
It is possible to create the file on the file system of the web server. I think the class java.io.File can achieve this.'
Benny
 
Kaustubh Patil
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Megan Hill:
Is it possible to create a folder or a file on the web server from a servlet?
If so, How can I do it ?
Thanks

Hi Megan,
You surely can create a folder on the web server. But only if the folder is inside the context of the servlet. I do not think that if you are trying to create a folder outside the context you will be able to do it.
Let me know if I am correct.
-Kaustubh.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You surely can create a folder on the web server. But only if the folder is inside the context of the servlet.

I have no idea what is meant by this.
Eseentially, you can manipulate the file system on the server (since that is where your servlet code is running) in any way that is allowed by the file-system persmissions granted to the user under which the web server is being executed.
And as pointed out earlier, the java.io classes are the mean you would use just like any other Java program.
hth,
bear
[ August 25, 2003: Message edited by: Bear Bibeault ]
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No contexts, sandboxes or specialized rules apply. If you can create the folder from a standalone java app - which basically means that you can create the folder from a command-line prompt, you can create the folder using java.io.File in a servlet, JSP or any other server-side code.
Your only restriction is that whatever OS filesystem security is in effect for the user and group IDs that the server runs under applies to the java code as well.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!