The project structure is as follows:

enter image description here

All jsp are in the WEB-INF directory and therefore just do not knock on them.

Attention question!

There is a header.jsp page that generates a header like this:

enter image description here

"Login" and "Registration" links and depending on conditions

<a href="bla-bla" class="navbar-link" name="LogIn" style=" color: #f0ffff;"> <c:choose> <c:when test="${not pageContext.session['new']}"> <c:choose> <c:when test="${user != null}"> <c:out value="Welcome,${user.getName()}"/> </c:when> <c:otherwise> <c:out value="Войти"/> </c:otherwise> </c:choose> </c:when> <c:otherwise> <c:out value="Войти"/> </c:otherwise> </c:choose> 

 <a href="#" class="navbar-link" style="color: #f0ffff;"> <c:choose> <c:when test="${not pageContext.session['new']}"> <c:choose> <c:when test="${user != null}"> <c:out value="Выйти"/> </c:when> <c:otherwise> <c:out value="Регистрация"/> </c:otherwise> </c:choose> </c:when> <c:otherwise> <c:out value="Регистрация"/> </c:otherwise> </c:choose> </a> 

display one or another text. How to properly implement a redirect to a jsp located in the WEB-INF directory, while setting the address in the href attribute?

For example, with the type = "submit" button there is no such question, because in the controller, I get the name from the request and redirect to another jsp and everything is fine, it works, but in this situation the link is necessary. Maybe it can also be somehow processed in the controller, if so, how? If it is possible to solve this problem in another way, I will be glad to hear suggestions.

    1 answer 1

    Problem solved. The solution was on the surface. Example with the authorization page href = "$ {pageContext.request.contextPath} / login". In the controller mapim login and there is a long-awaited redirect.

    • one
      pancake ... You like use Spring MVC? So use it, read about MVC, about DispatcherServlet, about mapping and annotations ... and don't put the application logic in the view. - barmaglott 8:49 pm