Thank all you guys very much for replying to my post.

I did map my servlet to the url-pattern "/". Is there any setting
could let web browsers find the static content inside the webapp
directory? If I put the static content into some other places, can web
browsers find the css file?

Does Jetty work the same way as Tomcat regarding this problem?

I have tried putting the webapp content in either ROOT directory or
mywebapp directory inside Tomcat/webapps. Web browsers could not find
the css file.

I copied the content of web.xml below.


<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd";
  version="3.1"
  metadata-complete="true">

  <servlet>
    <servlet-name>search</servlet-name>
    <servlet-class>com.dealfar.mainpage</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>search</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
<!--  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>
-->

</web-app>

On Tue, Mar 8, 2016 at 5:02 AM, Chris Gamache <cgama...@gmail.com> wrote:
> Chuck,
>
> That's precisely the point I was trying to make.
>
> CG
>
> On Mon, Mar 7, 2016 at 2:05 PM, Caldarale, Charles R <
> chuck.caldar...@unisys.com> wrote:
>
>> > From: Chris Gamache [mailto:cgama...@gmail.com]
>> > Subject: Re: Tomcat can not locate the folders of CSS files inside a web
>> app,
>> > if the url-pattern of a servlet is set to / inside web.xml
>>
>> > /mywebapp/css/style.css is where that file should be located if exists in
>> > the spot indicated in the tree diagram.
>>
>> > I don't think the default servlet plays in to this...
>>
>> Clearly it does, as Violeta stated.  Since the webapp is overriding the
>> mapping for "/", Tomcat's DefaultServlet will never get used, so there is
>> _nothing_ available to deliver static content.
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>> MATERIAL and is thus for use only by the intended recipient. If you
>> received this in error, please contact the sender and delete the e-mail and
>> its attachments from all computers.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to