There may be a work-around for this but I what I really want to know
is why it doesn't work.
I am following the MVC design pattern in building a simple test web
application using Tomcat 6.0.10 on Mac OS Tiger.
MVC pattern suggests every webapp request be handled by a servlet.
Static content rendered by forwarding the request to a jsp page.
Dynamic content is handled by java code and presentation by css (in my
app).
I am confused over the apparent inconsistent behavior observed when
specifying a servlet-mapping in web.xml with a url-pattern = '/'
against other url-patterns. Is this a bug in tomcat?
For Example:
I have a web application on my filesystem (deployed with default
build.xml) under: $CATALINA_HOME/webapps/ixania.
My web.xml file defines a servlet named BootStrap with a mapping like this:
<servlet-mapping>
<servlet-name>BootStrap</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping >
The BootStrap servlet only does one thing on an http GET request:
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/tmp.jsp");
dispatcher.forward(request, response);
tmp.jsp only contains a single string as context in the <body>: FOOBAR
When I navigate to http://localhost/ixania, I see FOOBAR in the browser.
When I add a <link> reference to tmp.jsp to locate a css file:
link href="<%= request.getContextPath() %>/css/tmp.css"
rel="stylesheet" type="text/css">
The css never gets resolved. The css is on the filesystem at
$CATALINA_HOME/ixania/css/tmp.css
When I change the url-pattern in web.xml to
<url-pattern>/ixania</url-pattern> and navigate to
http://localhost/ixania/ixania the context is display and the css is
applied.
This seems like a tomcat bug to me since I have simply substituted '/'
for '/ixania' in both the url-pattern and the actual URL.
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]