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

2016-03-07 Thread Caldarale, Charles R
> From: Junqiang Zhang [mailto:junqiangzh...@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

Don't top-post.  See item 6 under 
http://tomcat.apache.org/lists.html#tomcat-users

> I did map my servlet to the url-pattern "/".

The point we're trying to make is that you must not use a servlet mapping of 
"/" unless your servlet can handle the duties of DefaultServlet, including 
delivering static content such as CSS files and images.  Your mappings need to 
be more specific (as you appear to have already discovered, based on your first 
message).

> 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?

Note that web browsers do not "find" the content inside the webapp directory; 
that's entirely up to the servlets of the webapp, including Tomcat's built-in 
DefaultServlet - if you haven't disabled it by mapping something else to "/".  
Correct your servlet mapping and things will work as desired.

 - 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



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

2016-03-07 Thread Junqiang Zhang
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.




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">

  
search
com.dealfar.mainpage
  

  
search
/
  




On Tue, Mar 8, 2016 at 5:02 AM, Chris Gamache  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



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

2016-03-07 Thread Chris Gamache
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
>
>


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

2016-03-07 Thread Caldarale, Charles R
> 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



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

2016-03-07 Thread Chris Gamache
Junqiang Zhang has the expectation of the paths to the files correct.
/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...

Can you post your web.xml ? I think perhaps one of your mappings is sitting
on "/*" which would keep tomcat from serving static resources.

On Mon, Mar 7, 2016 at 1:52 PM, Violeta Georgieva 
wrote:

> Hi,
>
> 2016-03-07 19:37 GMT+02:00 Junqiang Zhang :
> >
> > I have tested on Tomcat versions 8.0.30, 8.0.32, and 9.0.0.M3.
> >
> > A web app is put inside a folder (let's say the name of the foder is
> > mywebapp) inside the Tomcat webapps directory. The folder for css
> > files (let's say the name of folder is css) is located inside this web
> > app folder. There is no index.html or index.jsp inside the web app
> > folder. The structure is as the follows.
> >
> > Tomcat
> > webapps
> > ---mywebapp
> >  ---css
> >   ---styles.css
> >  ---images
> >  ---META-INF
> >  ---scripts
> >  ---WEB-INF
> >  ---classes
> >   ---someservlet.class
> > ---lib
> > ---src
> > ---someservlet.java
> >---web.xml
> >
> >
> > If the url-pattern of someservlet.class is set to / inside web.xml,
>
> Tomcat's "default" servlet [1] is mapped to "/".
> The "default" servlet is a servlet that serves static resources as well as
> serves the directory listings (if enabled).
>
> You should know that when you map your servlet to "/" then you will
> override the "default" servlet mapping.
> So you should ensure that your servlet will do the same as "default" one in
> order to serve the static resources.
>
> When you map your servlet to "/someclass" then the static resources will be
> served by "default" servlet as expected.
>
> Regards,
> Violeta
> [1] http://tomcat.apache.org/tomcat-8.0-doc/default-servlet.html
>
> > someservlet.class can be access using
> > http://www.somewebsite.com/mywebapp
> >
> > The problem is that web browsers cannot locate styles.css at
> > http://www.somewebsite.com/mywebapp/css/styles.css. Therefor,
> > styles.css cannot be applied on the html file generated by
> > someservlet.class. Probably other folders or files inside mywebapp
> > directory cannot be accessed by web browsers too.
> >
> > If the url-pattern of someservlet.class is set to /someclass inside
> > web.xml, someservlet.class can be access using
> > http://www.somewebsite.com/mywebapp/someclass . Web browsers can
> > correctly locate styles.css at
> > http://www.somewebsite.com/mywebapp/css/styles.css
> >
> > Any solution to this problem? Does it solve this problem if I use
> > Jetty or Glassfish?
> >
> > Thanks.
> > Junqiang
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
>


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

2016-03-07 Thread Violeta Georgieva
Hi,

2016-03-07 19:37 GMT+02:00 Junqiang Zhang :
>
> I have tested on Tomcat versions 8.0.30, 8.0.32, and 9.0.0.M3.
>
> A web app is put inside a folder (let's say the name of the foder is
> mywebapp) inside the Tomcat webapps directory. The folder for css
> files (let's say the name of folder is css) is located inside this web
> app folder. There is no index.html or index.jsp inside the web app
> folder. The structure is as the follows.
>
> Tomcat
> webapps
> ---mywebapp
>  ---css
>   ---styles.css
>  ---images
>  ---META-INF
>  ---scripts
>  ---WEB-INF
>  ---classes
>   ---someservlet.class
> ---lib
> ---src
> ---someservlet.java
>---web.xml
>
>
> If the url-pattern of someservlet.class is set to / inside web.xml,

Tomcat's "default" servlet [1] is mapped to "/".
The "default" servlet is a servlet that serves static resources as well as
serves the directory listings (if enabled).

You should know that when you map your servlet to "/" then you will
override the "default" servlet mapping.
So you should ensure that your servlet will do the same as "default" one in
order to serve the static resources.

When you map your servlet to "/someclass" then the static resources will be
served by "default" servlet as expected.

Regards,
Violeta
[1] http://tomcat.apache.org/tomcat-8.0-doc/default-servlet.html

> someservlet.class can be access using
> http://www.somewebsite.com/mywebapp
>
> The problem is that web browsers cannot locate styles.css at
> http://www.somewebsite.com/mywebapp/css/styles.css. Therefor,
> styles.css cannot be applied on the html file generated by
> someservlet.class. Probably other folders or files inside mywebapp
> directory cannot be accessed by web browsers too.
>
> If the url-pattern of someservlet.class is set to /someclass inside
> web.xml, someservlet.class can be access using
> http://www.somewebsite.com/mywebapp/someclass . Web browsers can
> correctly locate styles.css at
> http://www.somewebsite.com/mywebapp/css/styles.css
>
> Any solution to this problem? Does it solve this problem if I use
> Jetty or Glassfish?
>
> Thanks.
> Junqiang
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>