How to serve a static content with tomcat?

196 Views Asked by At

I'm learning j2ee and try to develop my first web application with servlet api 4. But I have some problems with static content such as css files or images. Tomcat doesn`t skip the request to static content. How can I resolve this problem? Here is my project structure structure

and here piece of jsp file where I want to include my css files and images

<link rel="shortcut icon" href="${pageContext.servletContext.contextPath}/static/images/logo.png" type="image/png"> <link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/static/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/static/css/simple-sidebar.css">

but I have such errors in browser: errors list

1

There are 1 best solutions below

1
Dmitry Kulinich On

I find solution for my problem. If you need to include some css file to your jsp page you can do just like this

<style type="text/css"> <%@include file="resources/static/css/bootstrap.min.css" %> </style>