Can I put private servlet files in the WEB-INF directory?

W

William Krick

I am currently experimenting with a servlet that makes use of data
files to store information. I'd prefer that these files be NOT
publicly accessible but
I don't know if it's ok to put my own files into the WEB-INF directory
to "hide" them from users or if I should put them in a
hidden/protected folder OUTSIDE the deployment directory.

Is there a general consensus on this?

....
Krick
 
J

John C. Bollinger

William said:
I am currently experimenting with a servlet that makes use of data
files to store information. I'd prefer that these files be NOT
publicly accessible but
I don't know if it's ok to put my own files into the WEB-INF directory
to "hide" them from users or if I should put them in a
hidden/protected folder OUTSIDE the deployment directory.

Is there a general consensus on this?

You can put anything you want into WEB-INF/, as long as it doesn't
conflict with the files that the Servlet container expects to find
there. It sounds like your planned use is perfectly in line with its
purpose. Indeed, I think that having your servlet rely on non-shared
files outside its deployment directory is a much worse idea than using
WEB-INF. Best might be to put the files specifically in
WEB-INF/classes, from which location they can be located by your
servlet's ClassLoader (e.g. w/ getResource() or getResourceAsStream()).


John Bollinger
(e-mail address removed)
 
W

William Krick

John C. Bollinger said:
You can put anything you want into WEB-INF/, as long as it doesn't
conflict with the files that the Servlet container expects to find
there. It sounds like your planned use is perfectly in line with its
purpose. Indeed, I think that having your servlet rely on non-shared
files outside its deployment directory is a much worse idea than using
WEB-INF. Best might be to put the files specifically in
WEB-INF/classes, from which location they can be located by your
servlet's ClassLoader (e.g. w/ getResource() or getResourceAsStream()).

Actually, the servlet is an instance of the HSQLDB database and it
handles all the file activity itself. I just need to give it a path.
Thanks again for your input.

....
Krick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top