0

I'm wrting a web app on a local tomcat server. I've created a home page called index.jsp which has an html layout which uses bootstrap. It looks as it should when i run the server, but when i redirect any attributes to the index.jsp, using servlet, the layout completely crashes. This is my servlet:

@WebServlet(name = "HomeServ",urlPatterns = "/")
public class HomServ extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ArrayList<Solution> list  = Solution.loadAllSolutions();
        request.setAttribute("list",list);
        getServletContext().getRequestDispatcher("/index.jsp").forward(request,response);
    }
}

This is my index.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/CSS_BOOTSTRAP/boot/bootstrap.min.css" >
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


</head>
<body style="font-family: Bookman, dsTimes, serif; background-color:     #558C89">



<nav class="navbar navbar-inverse" style="height: 25px" >
    <div class="container-fluid">
        <div class="navbar-header" style="border-right: 1px solid grey; border-right-width: thin;">
            <a class="navbar-brand" href="index.html">Strona glowna</a>
        </div>
        <ul class="nav navbar-nav">


            <li><a href="PodStrona/index.html" style="border-right: 1px solid grey">Grupy</a></li>
            <li><a href="podstrona - kontakt/index.html" style="border-right: 1px solid grey">Kontakt</a></li>

        </ul>
        <img src="CSS_BOOTSTRAP/images/fsaf.png" style="margin-left: 515px;margin-top: 3px" >

        <div style="float: right; margin-top: 0; margin-right: 17px; height: 49px">
            <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#exampleModal" style="border-radius: 0%; height: 49px">Administrator</button>
        </div>

        <<div style="float: right; margin-top: 0; margin-right: 17px; height: 49px">
        <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#exampleModal" style="border-radius: 0%; height: 49px">Zaloguj sie</button>
    </div>



        <div style="float: right; margin-top: 0; height: 27px; margin-right: 20px; margin-top: 10px">
            <iframe src="http://free.timeanddate.com/clock/i6bku4wf/n262/fn5/fs22/fc808080/tct/th1" frameborder="0" width="100" height="25" allowTransparency="true" style="margin: auto;"></iframe>
        </div>



</nav>
<table>
<c:forEach items="${list}" var="list">
        <tr>
            <td>${list.description}</td>
            <td>${list.user_id}</td>
            <td>${list.exercise_id}</td>
        </tr>
</c:forEach>
</table>




<div style=" position: fixed; left: 0;bottom: 0; width: 100%; background-color: black; color: white; text-align: center;">
    <p style="font-size: 15px"> Aplikacja webowa by Bruno Kędzierski | <a href="https://github.com/BrunoKedzierski">GitHub</a> </p>
</div>


</body>
</html>

As you can see, my Bootstrap and all the resources (images, fonts) I've added to my project and i link a folder within my project for stylesheet(<link rel="stylesheet" href="/CSS_BOOTSTRAP/boot/bootstrap.min.css" >). I recon that this is the reason why it crashes but i am not sure.

Bruno
  • 92
  • 1
  • 8
  • What is the context path of your app? Is it /CSS_BOOTSTRAP? Is your app the root application? If not, you need to prepend the context path, using ``. Or simply to use the CDN, as you're already doing to load the bootstrap JS. – JB Nizet Aug 10 '18 at 21:56
  • *I recon that this is the reason why it crashes but i am not sure*: then open the network panel of your browser dev tools, and reload the page. You should see if you get a 200 OK or an error (404) when the browser tries loading the CSS). – JB Nizet Aug 10 '18 at 21:57

0 Answers0