CMS - Approach to handle requests using directory names
Jeppe Sommer
Ranch Hand
Joined: Jan 07, 2004
Posts: 263
posted
0
Hello,
In a content management system pages are often requested by using URL directory names (path) instead of using an unique parameter id, when getting content stored in a database, i.e:
Solution 1: URL request using directory name:
www.myDomain.com/about/
www.myDomain.com/about/thisDepartment/
Solution 2: URL request using unique parameter id:
www.myDomain.com?page.jsp?pid=233
I am looking for an approach on how to use the directory name (path) as the unique id, like solution 1.
I am wondering about if there is any good practice on how to handle URL request using directory names? I guess we will need some main class or jsp page handling the request, getting the requested URI path and the getting the content related to the unique directory name '/about/thisDepartment/'.
Can anyone help me with some ideas? Do we use servlet listener, a 404 page, a basic RequestDispatcher to handle this?
Great, now I got a better chance to google it on the internet. Thanks.
I have some other questions regarding this approach:
I guess the front controller is a basic servlet. The front controller gets the path info from the http request, and use a RequestDispatcher object that forward to the jsp page using the path info as parameter?
If this is how it could be done, I guess we are using the path info as the unique id to get content from the database and not a unique record parameter like 'pid=233'
I also guess that the front controller is handling every single http request. How do we avoid it to run in an infinite loop if it´s called for each request, like?
Create another prefix that always directs to your front controller. You just can't map /* because that will field all requests for everything! Including images, stylesheets, JavaScript files, etc.
Jeppe Sommer
Ranch Hand
Joined: Jan 07, 2004
Posts: 263
posted
0
Bear Bibeault wrote:Create another prefix that always directs to your front controller. You just can't map /* because that will field all requests for everything! Including images, stylesheets, JavaScript files, etc.
Okay, maybe I´m 'dull-witted' :-), but if I create a prefix called 'myPrefix', like:
- well then all links on the website has to point to this prefix, like: