Q: How to get e.g. registration.jsp view appear correctly in browser? I am following this tutorial for a login and registration functionality in a Spring Boot web application: https://hellokoding.com/registration-and-login-example-with-spring-security-spring-boot-spring-data-jpa-hsql-jsp/
I can't get the views to display properly - instead of e.g. the registration.jsp view page, I see the following string on screen, which is returned by my GET registration controller method: https://ibb.co/XXXtdSZ
I am new to Java, Spring Boot and even newer to JSP.
I am using IntelliJ Community Edition 2017.3.5 and I had a notification that .jsp files are not supported. Following this, https://stackoverflow.com/a/36572413/11451547, I went to Settings - File Types - HTML under Recognized File Types, and I added a new registered pattern, .*jsp, overriding the already existing registered pattern for JSP Files (syntax Highlighting Only). The message that .jsp was not supported disappeared but I still don't see the view pages properly.
In my registration.jsp I see a lot of 'namespace e.g.'form' is not bound' notifications. In my login.jsp, which has the same display issue (on screen I see the string 'login' instead of the login view), I have one notification - 'Namespace 'c' is not bound'.
Could you help with some ideas on how to display the views correctly?
Thank you!
This is the respective part of my controller (maybe I am wrong in adding @ModelAttribute to GET registration twice, this is part of the amendments I did to the tutorial code but e.g. my GET login controller method is the same as in the tutorial):
@GetMapping("/registration")
    public String registration(Model model) {
        model.addAttribute("userForm", new User());

        return "registration";
    }

@PostMapping("/registration")
    public String registration(@ModelAttribute("userForm") User userForm, @ModelAttribute("roleId") Long roleId, BindingResult bindingResult) { //diff w tutorial
        userValidator.validate(userForm, bindingResult);
//        userValidator.validate(roleId, bindingResult);

        if (bindingResult.hasErrors()) {
            return "registration";
        }
        userService.saveUser(userForm, roleId);

        securityService.autoLogin(userForm.getUserName(), userForm.getPasswordConfirm());

        return "redirect:/welcome";
    }

    @GetMapping("/login")
    public String login(Model model, String error, String logout) {
        if (error != null)
            model.addAttribute("error", "Your username and/or password is invalid.");

        if (logout != null)
            model.addAttribute("message", "You have been logged out successfully.");

        return "login";
    }

    @GetMapping({"/", "/welcome"})
    public String welcome(Model model) {
        return "welcome";
    }

My registration.jsp:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<c:set var="contextPath" value="${pageContext.request.contextPath}">

<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="utf-8">
      <title>Create an account</title>

      <link href="${contextPath}/resources/css/bootstrap.min.css" rel="stylesheet">
      <link href="${contextPath}/resources/css/common.css" rel="stylesheet">
  </head>

  <body>
    <div class="container">
        <form:form method="POST" modelAttribute="userForm" modelAttribute="roleId" class="form-signin">
            <h2 class="form-signin-heading">Create Your Account</h2>
            <spring:bind path="userName">
                <div class="form-group ${status.error ? 'has-error' : ''}">
                    <form:input type="text" path="userName" class="form-control" placeholder="Enter your username"
                                autofocus="true"></form:input>
                    <form:errors path="userName"></form:errors>
                </div>
            </spring:bind>

            <spring:bind path="password">
                <div class="form-group ${status.error ? 'has-error' : ''}">
                    <form:input type="password" path="password" class="form-control" placeholder="Enter your password"></form:input>
                    <form:errors path="password"></form:errors>
                </div>
            </spring:bind>

            <spring:bind path="passwordConfirm">
                <div class="form-group ${status.error ? 'has-error' : ''}">
                    <form:input type="password" path="passwordConfirm" class="form-control"
                                placeholder="Confirm your password"></form:input>
                    <form:errors path="passwordConfirm"></form:errors>
                </div>
            </spring:bind>

            <button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
        </form:form>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="${contextPath}/resources/js/bootstrap.min.js"></script>
  </body>
</html>

My login.jsp:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<c:set var="contextPath" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="utf-8">
      <title>Log in with your account details</title>

      <link href="${contextPath}/resources/css/bootstrap.min.css" rel="stylesheet">
      <link href="${contextPath}/resources/css/common.css" rel="stylesheet">
  </head>

  <body>
    <div class="container">
      <form method="POST" action="${contextPath}/login" class="form-signin">
        <h2 class="form-heading">Log In</h2>
        <div class="form-group ${error != null ? 'has-error' : ''}">
            <span>${message}</span>
            <input name="userName" type="text" class="form-control" placeholder="Enter your username"
                   autofocus="true"/>
            <input name="password" type="password" class="form-control" placeholder="Enter your password"/>
            <span>${error}</span>
            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>

            <button class="btn btn-lg btn-primary btn-block" type="submit">Log In</button>
            <h4 class="text-center"><a href="${contextPath}/registration">Create an Account</a></h4>
        </div>
      </form>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="${contextPath}/resources/js/bootstrap.min.js"></script>
  </body>
</html>

My welcome.jsp:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="contextPath" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome</title>

    <link href="${contextPath}/resources/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
  <div class="container">
    <c:if test="${pageContext.request.userPrincipal.name != null}">
        <form id="logoutForm" method="POST" action="${contextPath}/logout">
            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
        </form>

        <h2>Welcome ${pageContext.request.userPrincipal.name} | <a onclick="document.forms['logoutForm'].submit()">Logout</a></h2>
    </c:if>
  </div>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  <script src="${contextPath}/resources/js/bootstrap.min.js"></script>
</body>
</html>

The respective part of my application.yml file:
spring:
  main:
    banner-mode: 'off'
  datasource:
    url: jdbc:mysql://localhost:3306/inspire_me_db?useSSL=false
    username: springuser
    password: ThePassword
  jpa:
    hibernate:
      ddl-auto: update
  flyway:
    baselineOnMigrate: true
  mvc:
    view:
      prefix: /
      suffix: .jsp
  messages:
    basename: validation

The respective part of my pom.xml:
<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
</dependency>

My package structure:
https://ibb.co/Qr2dmNr

A: Can you try registering your jsp view resolver as follows :
@Configuration
@EnableWebMvc
@ComponentScan
public class MvcConfiguration implements WebMvcConfigurer
{
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/view/");
        resolver.setSuffix(".jsp");
        resolver.setViewClass(JstlView.class);
        registry.viewResolver(resolver);
    }
}

Or you can also specify jsp as the view resolver in Spring-boot by providing the following in application.properties or yml :
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp

Verify that the prefix provided points to the correct directory in which the jsp files reside.Usually the jsp files are put under src/main/WEB_INF/view .
Also since you are using spring-boot , if you don't have the appropriate dependencies to compile the jsp add the following to the pom :
<!-- JSTL -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
<!-- To compile JSP files -->
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

