aspose file tools
The moose likes Servlets and the fly likes create a directory under the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "create a directory under the servlet" Watch "create a directory under the servlet" New topic
Author

create a directory under the servlet

Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
is it possible to create a directory under the web-inf folder?

I'm to create a directory at the moment a user registers:

say login: john

than creates: web-inf/users/john

I'm using:
File newDir = new File(servlet.getServletContext().getRealPath("/WEB-INF/users/")+userDAO.getLogin()+"/");

but it does't create, when I change the dir to outside the web-inf it acepts

if its not possible, how can I create the dirs without exposing them?

thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Does the WEB-INF/users directory already exist?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56179
    
  13

Originally posted by Mike Dikta:
is it possible to create a directory under the web-inf folder?
There is no web-inf folder; it's WEB-INF.

This is not advised. What happens if your app needs to be redeployed from its war? You should create such folders outside the bounds of the web application.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
Originally posted by Bear Bibeault:
There is no web-inf folder; it's WEB-INF.

This is not advised. What happens if your app needs to be redeployed from its war? You should create such folders outside the bounds of the web application.


and how can I protect it?


thanks guys, problem solved
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Mike Dikta:
and how can I protect it?

If it's not inside the webapp's directory stucture, it will not be directly accessible to the web.

thanks guys, problem solved

What it was?
Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
Originally posted by Ben Souther:

What it was?


File newDir = new File(servlet.getServletContext().getRealPath("/WEB-INF/users//")+userDAO.getLogin()+"/")

I put an extra "/"
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: create a directory under the servlet
 
Similar Threads
jstl and netbeans
root context need help
Creating Application Resource with MyEclipse
Servlets-3b Ant deploy issue
image does not display on JSP page w/ Tomcat server