Using a title of "Servlet question" in a forum completely dedicated to questions on Servlets isn't very helpful. What everyone named their post "Servlet question"?
Please go back and change your post to add a more meaningful subject by clicking the
Also, please read this with regards to using the term "urgent".
Bart Stanz wrote:Hi, you know on digg.com when you click on an article "This is an article" it links to a url in the form digg.com/this_is_an_article. Is this possible to do with Servlets? Seems like the parameter is being passed as part of the url but not using the typical ?story=this_is_an_article. I tried google but not sure what it's called.
This is called URL rewriting or friendly URLs. In servlet containers like tomcat it can be done with UrlRewriteFilter.
check out http://www.theserverside.com/blogs/thread.tss?thread_id=47588
If you are using a web framework like struts 2, it should let you swap out the ActionMapper for one that uses friendly URLs. If you are doing straight servlets, you will have to do it yourself with URLRewriteFilter.
In my case this worked out fine:
I made a servlet mapping with url-patter like this:
and then in the servlet I put this code:
String servletPath = request.getPathInfo();
So if the URL was www.site.com/article/this_is_some_article, request.getPathInfo(); would return /this_is_some_article.