1

This line:

/${initParam['webinf']}${initParam['test']}header.jsp

Prints out:

/WEB-INF/test/header.jsp and if I copy this into:

<%@ include file="/WEB-INF/test/header.jsp" %> it works perfectly.

However, if I use the first line of code directly in the statement like this:

<%@ include file="/${initParam['webinf']}${initParam['test']}header.jsp" %>

I get the error:

Sun Feb 16 15:03:56 GMT 2014: org.apache.jasper.JasperException: /WEB-INF/test/index.jsp (line: 10, column: 9) File "/${initParam['webinf']}${initParam['test']}header.jsp" not found

  • Include directives don't parse EL. A dynamic include might, or you could use something more like actual templating. Static includes happen at compile time, the values aren't known, and it doesn't do late evaluation. – Dave Newton Feb 16 '14 at 15:16
  • Use a dynamic include? What's the point of using a context paran, though? Easier to change the JSP, and no restart is required. – Dave Newton Feb 16 '14 at 15:30
  • 1

1 Answers1

2

You should use

  <jsp:include page="..." /> 

This will evaluate JSP EL in "...".

Some more info here Include another JSP file

Community
  • 1
  • 1
Vitaly
  • 2,760
  • 2
  • 19
  • 26