-1

How would I use a stylesheet (CSS) in the JSP pages found in WEB-INF (Netbeans)?

This is what I've tried:

<!DOCTYPE html>
  <html > 
    <head>
      <meta charset="UTF-8"> 
      <title>Tennis</title> 
      <link rel="stylesheet" type="text/css" href="/WEB-INF/style.css"> 
    </head> 
    <body> 
Jean-Paul
  • 127
  • 2
  • 15
  • Please don't post your code in comments section instead use StackOverflow [code snippets](http://stackoverflow.com/editing-help) – Shashanth Apr 08 '17 at 17:23
  • 2
    There are 2 questions here, and they are completely different. your 1st question is good, but the second is going to need to be created in a new questions and requires a lot more information about what you are trying – muttonUp Apr 08 '17 at 23:53
  • Welcome to Stack Overflow! I've edited the code from the comment into your question. You can further edit your question by clicking on the "edit" link below your post. As others have pointed out, you really have two questions here. The question why you get a null pointer is a separate one. You should consult our canonical ["What is a NullPointerException, and how do I fix it?"](http://stackoverflow.com/q/218384/812149) for that. If the answers there don't help, you can ask a new question. – S.L. Barth is on codidact.com Apr 12 '17 at 06:52
  • thanks a lot. I solved both ! Thanh you again !!! – Jean-Paul Apr 14 '17 at 21:03

1 Answers1

2

Don't keep your CSS or JavaScript files inside the WEB-INF directory. According to this StackOverflow thread, "WEB-INF resources are accessible to the resource loader of your Web-Application and not directly visible to the public".

Instead of that create your project files structure like below,

screenshot 1

Later your can use/refer your CSS files like below.

<!DOCTYPE html>
<html > 
  <head> 
    <meta charset="UTF-8"> 
    <title>Tennis</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
  </head> 
  <body>
  ...
  </body>
</html>
Community
  • 1
  • 1
Shashanth
  • 4,995
  • 7
  • 41
  • 51