0

I was building a small application to test the functionality of the JSP files in Java, my application only has a controller which maps the endpoint and one(for now) JSP file which is the "home" of the mapping.

Here I will post the code, the POM and the application.properties.

I tried to use the WAR packaging and another version of SDK and JRE, but still I get this type of error, which is weird since im the only one getting it. Also tried to run the jar file from the target directory, it worked yesterday on another project, but now I'm getting the same problem over and over.

application.properties:

spring.application.name=valutadivisoreperfetto
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
server.port=8080

logging.level.web=DEBUG
logging.level.org.springframework.web=DEBUG
# Attiva debug per i view resolver
logging.level.org.springframework.web.servlet.view=TRACE

home.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.tags.core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    //html and css are there, i cut them since they are pretty useless to include

Controller:

@Controller
public class CheckNumeroController {

    @GetMapping("/")
    public String home(){
        return "home";
    }

this is my file's path, as you can see the JSP files are in the correct path

this is what I see in the terminal when I try to go to http://localhost:8080/:

2025-05-07T12:21:29.798+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/", parameters={}
2025-05-07T12:21:29.839+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to it.prova.valutadivisoreperfetto.controller.CheckNumeroController#mostraHome()
2025-05-07T12:21:29.879+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7]
2025-05-07T12:21:29.880+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.view.JstlView            : View name 'home', model {}
2025-05-07T12:21:29.889+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.view.JstlView            : Forwarding to [/WEB-INF/jsp/home.jsp]
2025-05-07T12:21:29.901+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2025-05-07T12:21:29.903+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : "ERROR" dispatch for GET "/error", parameters={}
2025-05-07T12:21:29.914+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2025-05-07T12:21:29.955+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2025-05-07T12:21:29.979+02:00 DEBUG 11668 --- [valutadivisoreperfetto] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from "ERROR" dispatch, status 404

thats my POM currently using Java 17 with the 3.2.3 version of spring boot

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Per supportare JSP -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>


        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jakarta.servlet.jsp.jstl</artifactId>
            <version>3.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
6
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a minimal reproducible example. Commented May 7 at 10:48
  • Try creating the webapp folder as a web module in the project settings. Commented May 7 at 12:15
  • 1
    Where is home.jsp file located in your source code? Commented May 7 at 12:35
  • the jsp file is located in src/webapp/WEB-INF/jsp, btw i posted a screen of the file path, its on the post Commented May 7 at 13:02
  • Reference Answer stackoverflow.com/questions/79575018/… Commented May 8 at 1:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.