JSP Eclipse Project - Linking CSS style page

0

How to properly link my stylesheets in my JSP Servlet project? Below is the structure of my project. I also do not know if the hierarchy is correct. Help me. I'vealreadytried../webapp/style/estilo.cssandnothing.Itriedmodifyingandputtingthestylesheetinthewebappfolderandlinking:

<linkrel="stylesheet" type="text/css" href="estilo.css" >

But it does not, and the type on the page is only one border, it does not pull everything ...

Home page.JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="br.edu.unilasalle.model.*" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"         
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <link href="style/estilo.css" rel="stylesheet"/>
</head>
<body class="fundo">
    <h1>Menu Principal</h1>
    <h3>Opções</h3>
    <a href='CadastroUsuario.jsp'>Cadastro de Usuário</a><br>
    <a href='CadastroBancos.jsp'>Cadastro de Bancos</a><br>
    <a href='CadastroCategorias.jsp'>Cadastro de Categorias</a>

<%
    if(request.getSession(true).getAttribute("usuario")!=null){

    Usuario usuario=        
   (Usuario)request.getSession(true).getAttribute("usuario");
%>
<p>
    Usuário: <%=usuario.getId()%>. <%=usuario.getNomeCompleto() %>   <a     
    href="LogoutController">Sair</a>
</p>

<%} %>
</body>
</html>

Style.css page

@CHARSET "ISO-8859-1";

body{
    background: rgba(0,77,153,0.6);
    border: 4px solid #8080c0;
    margin: 200px 500px 0px 500px;
    border-radius: 125px;
}

div {
    color: white;
    font-family: 'Times New Roman';
    font-size: 20px;
    padding: 80px;
    padding-bottom: 60px;
}

#acesso{
    margin-bottom: 5px;
    margin-left: 150px;
    font-family: 'Times New Roman';
    color: blue;
}

.fundo{
    background: url('../WebContent/img/wallpaper.jpg') no-repeat center;
    margin:0;
    padding:0;
    background-size:cover;
}
    
asked by anonymous 30.04.2017 / 15:20

1 answer

1

From what I read in your commentary you say that the only property that works is "Border: 4px".

So that means you're calling the style sheet correctly!

The problem is probably the style or the page .... Delete everything from your style sheet and change the background color of the page to test it.

If so, add one by one to the styles in your style sheet and check if they are working one by one.

Where do you call the div, the id #acesso ?

You have to call them on the jsp page !!! If you do not call it does not work !!

You just called here in this snippet of your code <body class="fundo"> you have to do the same for the other properties of your css.

<body class="fundo">
    <h1>Menu Principal</h1>
    <h3>Opções</h3>
<div>
    <a href='CadastroUsuario.jsp'>Cadastro de Usuário</a><br>
    <a href='CadastroBancos.jsp'>Cadastro de Bancos</a><br>
    <a href='CadastroCategorias.jsp'>Cadastro de Categorias</a>
</div>
<p id="acesso"> Isso é uma id</p>
<%
    if(request.getSession(true).getAttribute("usuario")!=null){

    Usuario usuario=        
   (Usuario)request.getSession(true).getAttribute("usuario");
%>
<p>
    Usuário: <%=usuario.getId()%>. <%=usuario.getNomeCompleto() %>   <a     
    href="LogoutController">Sair</a>
</p>

<%} %>
</body>

The way I used the div and id above is just an example, does not mean it has to be used exactly in these places, you are free to use wherever you want.

How to call the link, which is not the problem, try this:

<link href="style/estilo.css" rel="stylesheet" type="text/css">

or

<link rel="stylesheet" href="${pageContext.request.contextPath}/style/estilo.css" />  

In the first case above you can add ../ or remove to find the depth where your style page is. For example:

 <link href="../style/estilo.css" rel="stylesheet" type="text/css">
 <link href="../../style/estilo.css" rel="stylesheet" type="text/css">
...
    
30.04.2017 / 16:31