A common way to do this is to place the files away from the web root. Then users request the file from a
Servlet, the Servlet decides if the user is allowed to see the file. If they are, it loads the file from the directory structuure and streams it to the client.
This also supports dynamic folders.
The servlet maps to (for example) "/download/*", then files that are requested via /download/Dave/myFile gets routed through the servlet. If I'm not logged in as Dave, the servlet doesn't allow the operation.
Is this more or less what you were looking for?
Dave