0

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

  • Which request are you sending? What is the context path of your webapp? What is the contents of the war file? Provide the necessary details. Explain why you think a specific request should return the content of a specific file. – JB Nizet Jul 17 '18 at 12:22

1 Answers1

-1

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>

  • This is a terrible idea. Now all your HTML pages will contain all of the bootstrap CSS, instead of simply linking to it. Why don't you answer the questions you're being asked? – JB Nizet Jul 18 '18 at 11:58