tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: web.xml: my default.css file does not work correctly
Date Sat, 31 Jul 2004 18:43:16 GMT
You have overriddent the default servlet. That mean its your servlet's job to 
serve static resources. (There a threads in the archives about this)


-Tim

Jon Doe wrote:

> I thought I'd grasped the way the deployment descriptor works in Tomcat. 
> But I've still got problems I don't understand. In summary: my 
> default.css file does not work with this web.xml file:
> 
> <web-app>
> <servlet><servlet-name>Index</servlet-name>
> <servlet-class>com.wingtip.Index</servlet-class></servlet>
> 
> <servlet><servlet-name>Router</servlet-name>
> <servlet-class>com.wingtip.Router</servlet-class></servlet>
> 
> 
> <!-- Access to root invokes Index. -->
> <servlet-mapping><servlet-name>Index</servlet-name>
> <url-pattern>/</url-pattern></servlet-mapping>
> 
> <!-- All URLs end .myext. These are processed by the front controller. -->
> <servlet-mapping><servlet-name>Router</servlet-name>
> <url-pattern>*.myext</url-pattern></servlet-mapping>
> </web-app>
> 
> So there is a url-pattern for / -- the root URL, and there is a 
> url-pattern for anything ending *myext. All this works fine. I put all 
> the routing code into the Router.java file and this works like a dream. 
> It gives me the benefit of putting all this logic in one file, and so I 
> can see what is going on, and apply consistent security treatment to all 
> my URLs. Great!
> 
> But the fly in the ointment is CSS (and image files too). These appear 
> not to be available. How do I get round this? I have seen mention of a 
> 'default' servlet in the Servlet spec, but no more details. How do you 
> make all URLs that don't match your patterns 'fall through' so they can 
> be used by whatever notion of webserver exists in Tomcat?
> 
> Incidentally, it would be *really* nice to have just the one servlet 
> defined. Is it legal/possible to the reference to Index above removed 
> and add the / to the Router servlet?
> 
> One final point. I've heard mention that it is not good form to use a / 
> mapping. If not, what is the alternative?
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message