I'm looking for is a "Best Practices" approach for setting up Apache httpd (2.2) with Tomcat 6 so that we can:
Allow JSP files to be served for directory listings (e.g. http:/www.example.com displays index.jsp via DirectoryIndex index.jsp).
Hide the extensions of all URLs (both *.html and *.php files served by Apache and *.jsp served by Tomcat) to make them SEO friendly. So for instance, http:/www.example.com/about-us might resolve to about-us.jsp.
What I'm looking for is the "recommended" approach to do this (examples would be phenomenal). I'm aware of mod_rewrite, mod_jk, mod_proxy_ajp, and mod_proxy_http, but what I'm looking is pros/cons and any experience you folks may have with one or the other and how you went about setting it all up.
Any and all advice welcome.
Thanks
Here are the guidelines I'm familiar with:
Try to do as much as possible in your application without the use of Apache. This will make hosting your application easier and it will help you maintain your application, because all the logic is in one spot. Additional advantage: you don't need Apache to run your application locally.
A way to do it with tomcat is to use your web.xml. For example, to get to the homepage: /homepage.jsp
Here's an example of how you can map any url, in this case "/detailpage" to the /detailpage.jsp file:
<servlet>
<servlet-name>detail</servlet-name>
<jsp-file>/detailpage.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>detail</servlet-name>
<url-pattern>/detailpage</url-pattern>
</servlet-mapping>
For more information on using the web.xml file: http://code.google.com/appengine/docs/java/config/webxml.html
Now, this can become tedious when you have a lot of documents, but I guess in that case you would start using a CMS that fixed this for you, right? Here's how it's done in Hippo CMS for example: http://www.onehippo.org/7_7/library/concepts/request-handling/sitemapitem-matching.html.
On nice url's: I don't think it's considered bad practice to add .jsp or .html to detailpages. Personally I like .html for detailpages and just the name for overview pages, but I guess that's a matter of taste. Here's more background information the Dutch government gives about friendly url's: http://versie1.webrichtlijnen.nl/english/manual/development/production/permanent-unique-urls/friendly-urls/
Disclaimer: You shouldn't see the Hippo reference as an exclusive reference. I work for Hippo, so I referenced the URL matching implementation I know of. Other (Java based) CMS's which may have similar solutions can be found here: http://en.wikipedia.org/wiki/List_of_content_management_systems#Java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With