• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create a directory under the servlet

 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the WEB-INF/users directory already exist?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike Phillip
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:

What it was?


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

I put an extra "/"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic