dcsimg
Making a virtual directory structure
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, May 1, 2003 09:03 AM

I would like to create a servlet which would create a virtual directory structure. Here is what I want to do :



User sends request for http://www.foo.com/bar/baz/quux.html



barServlet gets the parameter baz/quux.html and generates the appropriate page using data from a database and a template.



Basically it creates a virtual structure which is generated on the fly.



I know I could do it using servlet parameters(ie.: http://www.foo.com/bar?url=baz/quux.html) but it would require parsing the links on the generated pages, something I am reluctant to do.



Is it possible? If so, how can I do it?

Re: Making a virtual directory structure

Posted By:   Anonymous  
Posted On:   Thursday, May 1, 2003 12:02 PM

I found the solution. Create a filter for the appropriate URL mapping, then generate the pages within the filter.



For example :

http://www.foo.com/bar/html/baz/quux.html



Supposing your web-app is installed in /bar, create a filter for mapping /html/*. It will get all requests for http://www.foo.com/bar/html/ and lower levels, even if there is no such directory or file. Then generate the response within that filter, stripping the web-app and /html/ part to obtain the name of the file to generate.

About | Sitemap | Contact