0

I'm working on a Java EE project for an online bookstore and I'm having trouble getting styles and images to load correctly when using RequestDispatcher. When I use RequestDispatcher to forward the request to my index.jsp file, the images don't load. However, if I redirect to the same JSP file, the images load correctly.

I've tried a few different things to troubleshoot the problem, including checking file paths and making sure that my server is properly configured to serve static content. However, I haven't been able to find a solution.

Here's the relevant code I'm using in my IndexServlet:

RequestDispatcher dispatcher = request.getRequestDispatcher("./views/index.jsp");
dispatcher.forward(request, response);

And here's an example of the HTML code in my JSP file that's not loading the styles and images:

<link rel="stylesheet" href="/resources/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="resources/assets/css/baguetteBox.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/vanilla-zoom.min.css">
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

0 Answers0