views:

96

answers:

1

I use Resin webserevr. There is great FileServlet class for serving static content. I'd like to remap URIs like

/user1/file.txt -> /users/dir1/1/file.txt
/user2/file.txt -> /users/dir2/22/file.txt
...

in runtime.

But username->path mapping is not static and based on some database data.

A: 

You would map your /user URLs to a servlet, which would in turn forward the request to Resin's FileServlet

   final String actualFilePath = dao.getFilePathFor("/user1/file.txt");
   final RequestDispatcher disp = request.getRequestDispatcher("/mystaticmapping" + actualFilePath);
   disp.include(request, response);
Jonathan Feinberg