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:
Solution 2: URL request using unique parameter id:
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?
Joined: Jan 07, 2004
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: