Using a servlet as a welcome-file

Written by Joseph Ottinger

It's very common to wish to use a servlet as a welcome-file.

However, no container seems to "get it right" outside of custom modifications to the specification. The problem is related to the specification. The Servlet Specification allows for welcome-file entries to be literal files and not resources, as servlets are. Thus, JSPs work fine as welcome-files, but not servlets. However, it's trivial to fool the container (any container, not just Orion) into using a servlet.

Here's what you do: Suppose you create a servlet that maps to a url-pattern, "action". The next step would be to create an empty file, called "action". The servlet engine will note that a file called "action" is a valid response, and process it - but because it matches the url-pattern of a servlet, the servlet will be invoked instead.

Copyright © 2007 IronFlare AB