Linking css built in eclipse to jsp and getting results

13,011

Solution 1

Tag (link) should be an empty-element tag.

This error message is telling you that your link tag needs a closing slash:

<link rel="stylesheet" href="css/first.css" type="text/css" /> <-- see the closing '/'

If that doesn't fix it, my guess is that your path is not quite right.

Solution 2

I changed in the

<head>
    <link rel="stylesheet" href="css/first.css" type="text/css">

to

<head>
    <style type="text/css">
    <%@include file="css/first.css" %></style>
</head>

and in my eclipse project explorer under the "WebContent" file i added a folder named "CSS" and moved first.css to that folder.

Although from what i read, this is a very inefficient way of linking it because it imports the entire css.

Share:
13,011
Trae Moore
Author by

Trae Moore

Currently looking for opportunities that are either remote or in Houston, Tx and/or the surrounding area.

Updated on November 23, 2022

Comments

  • Trae Moore
    Trae Moore over 1 year

    I am trying to link a css i created in eclipse to the jsp and when i run the project i get no results in my browser. I've tried it in multiple ways, by putting

    <link rel="stylesheet" href="css/first.css" type="text/css">
    
    <link rel="stylesheet" href="boe/WebContent/first.css" type="text/css">
    
    <link rel="stylesheet" href="(my full path to the file)" type="text/css">
    

    I've tried so much that i don't remember how i got it to not error out. i am getting this

    Tag (link) should be an empty-element tag. 
    

    as the caution error.

    i can not find any step by steps on creating the css and making it link to the jsp, so it can show up in my browser.

    here is my code for both the jsp and the css.

    jsp:

    <?xml version="1.0" encoding="UTF-8" ?>
    <%@ page import="java.util.*" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" href="css/first.css" type="text/css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>TestPage - Test1</title>
    </head>
    
    <body>
        <div id="page-container">Hello World</div>
        <%Date d = new Date(session.getLastAccessedTime());%>
        this page was last viewed <%= d.toString() %>
    </body>
    </html>
    

    css:

    @CHARSET "UTF-8";
    html, body {
        margin:0;
        padding:0;
    }
    
    #page-container {
        width: 760px;
        margin: auto;
        background: red;
    }
    

    any help on finding a step by step or if you have a good explanation, it would be much appreciated. Thank you

  • Trae Moore
    Trae Moore over 11 years
    Thank you for that. it took the error away, but still am getting no results for the css implementation.
  • Kevin Boucher
    Kevin Boucher over 11 years
    Don't you need the entire CSS? This would actually be more performant because it reduces the number of requests required to load the page and its resources.