0

I am just trying to add some simple css to my JSP page. My jsp page is located in the following directory; WebContent > WEB-INF>pages>Login.jsp | My css file is located here; WebContent > WEB-INF > css > Login.css

This is my JSP code.

<head>
<link rel="stylesheet" type="text/css" href="../css/Login.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
    <div>
        <form method="post">
            <table>
                <tr>
                    <td>
                        //some code
                    </td>
                </tr>
                <tr>
                    <td>
                        //some code
                    </td>
                </tr>
                <tr>
                    <td>
                        //some code
                    </td>
                </tr>
            </table>
        </form>
    </div>
</body>

and this is my CSS

table {
    border-width: 1px;
    border-color: black;
    border-style: solid;
}

I just wanted to make a border show around the table to see if it would work and it's not. There is no border around my table what so ever.

Any idea why this may not be working

Craig
  • 364
  • 1
  • 3
  • 25

4 Answers4

6

Probably the problem is path to your css file. First, try to remove your pages and css folder from your WEB-INF directory and put them next to WEB-INF. Then try this instead:

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/Login.css" /> 
hamed
  • 7,939
  • 15
  • 60
  • 114
1

If you are using the tomcat plugin through eclipse, try and right click on the server and press clean. I had this issue and it was because the css file wasnt getting updated by the server. By doing a clean it updates all of the files.

Just an idea.

Tango199
  • 52
  • 1
  • 6
0

just copy and past your both folder into web content and change path link rel="stylesheet" type="text/css" href="../css/Login.css"
your directory just like /WebContent/pages/Login.jsp and your css file directory /WebContent/css/table.css

Alex
  • 8,461
  • 6
  • 37
  • 49
damon
  • 65
  • 7
0

You can check what "../" resolves to using your browser. You might need to use "./" instead.
In your browser open developer tools (In chrome press F12) then go to the network tab. Browse to your page normally and watch the outgoing requests. You should see the request for your Login.css stylesheet. Hover over it to see the complete path it is using. Is this the correct path?

eToi
  • 1
  • 1
  • you should ideally explain the difference between "..?" and "./". we should never expect users to use a browser which we prefer, code should work on all browsers – Saurabh Jhunjhunwala May 04 '15 at 12:36
  • It is not resolved in the browser, it is resolved in the server. We are just using the browser to see what is going on. We are not expecting the user to use our browser either, again we are merely using the browser to have an understanding of the issue. – eToi May 04 '15 at 12:41