Howto: Smart URLs
I had a problem, I’m not afraid to admit it. The URL’s on my site sucked. Example: http://cubanlinks.org/go/post.do?id=5
Obviously, this is a consequence of creating a dynamic site. There is one post template page, and it loads data from MySql based on an id. Unfortunately, to search engines and logfile analyzers, your site seems like it only has one page (post.do).
But, thanks to a couple servlets, that’s all behind me. Now, instead of URLs looking like this:
...to looking like this:
For this example, I created a SectionServlet, mapped it to /section/*. The servlet parses its
request.getPathInfo(), which in this case would be /home/tech/, and forwards the request to the section Action (section.do) passing the appropriate parameters.