14

So I have a main JSP index page, "index.jsp", which has several includes. Something like,

<%@ include file="/WEB-INF/views/includes/jstl/include.jsp" %>
<%@ include file="/WEB-INF/views/includes/licenses/license.jsp" %>
<%@ include file="/WEB-INF/views/includes/generalHtml/header.jsp" %>
<%@ include file="/WEB-INF/views/includes/navigation/navbar.jsp" %>
<%@ include file="/WEB-INF/views/includes/generalHtml/footer.jsp" %>

The "include.jsp" contains a string "String basePath = request.getContextPath();".

"navbar.jsp" uses "basePath", but Eclipse puts a red X on any line of "navbar.jsp" that uses "basePath" with the message "basePath cannot be resolved".

My webapp works just fine, but wondering what might be causing this, or if it can be resolved? Or maybe there's a way to make Eclipse ignore this? I just want the false positive red X's to go away. I suppose Eclipse doesn't understand that "navbar.jsp" is getting "basePath" from "include.jsp" because it is compiled together with "index.jsp".

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
wsams
  • 2,499
  • 7
  • 40
  • 51

1 Answers1

18

Eclipse is an epic failure with regard to JSP/EL validation. Just ignore it or disable all (or parts of) JSP/EL validation in workspace preferences through Validation and/or Web > JSP Files > Validation.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 2
    Disabling the whole validation is the short answer. For the long answer and alternatives, have a look to http://stackoverflow.com/questions/16593952/java-variable-across-multiple-include-blocks-variable-cannot-be-resolved – Julien Kronegg Jun 20 '13 at 13:14
  • Any specific instructions what to disable? I tried to set all _Error_ to _Ignore_ but the errors persist (even after re-validation). I'm using Eclipse Neon.2. – Markus L Mar 01 '17 at 15:50