I would like to map requests to http://server/context to go to a servlet, say a servlet called Controller. If I put something like the following in the web.xml file for the webapp, I can sort of get what I want:
<servlet> <servlet-name>Controller</servlet-name> <servlet-class>net.mydomain.webapp.Controller</servlet-class> </servlet> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> But then, resources like *.jpgs and *.gifs are no longer served up. I suspect the reason for this is that all control is passed to the Controller object and thus I would have to explicitly code in support in Controller the ability to serve up those files. While this doesn't seem like it'd be hard to do, I can't help but get that "reinventing-the-wheel" feeling if I explicitly endow Controller the ability to do this. Another option I've considered is to setup a welcome file via the <welcome-file-list> tags in the web.xml file. Call this file "index.jsp" or something (lets assume that index.jsp isn't looked for by default here). And in "index.jsp" I just have a <jsp:forward> tag that immediately passes control to Controller. This approach certainly gives the appearance that the Controller servlet gets control whenever a user goes to http://server/context, but in reality index.jsp gets first dibs before it passes control to Controller. This solution, however, is probably better than the previous solution as it involves less work. And less work is always a good thing. One final option I've managed to come up with involves a combining of the previous two solutions. I set up the servlet mapping like so: <servlet> <servlet-name>Controller</servlet-name> <servlet-class>net.mydomain.webapp.Controller</servlet-class> </servlet> <servlet-mapping> <servlet-name>Controller</servlet-name> <url-pattern>/controller</url-pattern> </servlet-mapping> Then setup a welcome file like so: <welcome-file-list> <welcome-file>controller</welcome-file> </welcome-file-list> When I initially tried this, all I got was a directory listing of the webapp's root (I didn't have an index.jsp file in the root). Before giving up though I decided to make a zero-length file called "controller" in the webapp's root just to see what would happen. And to my amazement it worked! I guess Tomcat first checks to see if the welcome file actually exists, and if it doesn't fall back to whatever the default behavior is (in this case, produce a directory listing). If it does exist, then the servlet-mapping magic is allowed to do it's thing. This final solution is pefect except for one thing. I need to make a zero-length "dummy" file in order to "trick" Tomcat into doing what the servlet-mapping directives tell it to do. I suppose I can live with this, but is there an even better way to do this? Perhaps I'm going about this all wrong. Any help with this would be greatly appreciated. BTW, I am using Tomcat v4.0.3. Thanks! - Arcadio -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>