0

I have code which does <%@include file = "/webpages/includeFiles/header.jsp" %> which works fine.

However i want use it with request.getContextPath()

Something like <%@include file = "request.getContextPath ()/webpages/includeFiles/header.jsp" %>

I get a compilation error.

How can i achieve it ?

Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108

2 Answers2

1

You cannot include dynamic valuse in <%@include file = "">.

Use the standard action which accepts dynamic values <jsp:include page="<%=request.getContextPath()%>/firstPage.jsp"></jsp:include>

Prasad Kharkar
  • 13,410
  • 5
  • 37
  • 56
0

Instead of using static include, try using dynamic include

<jsp:include page='<%= request.getContentType()/webpages/includeFiles/header.jsp %>' />

I have not tested, try manipulating bit if not works.

You can take a look here: Include file from dynamic property value

Community
  • 1
  • 1
Jayesh
  • 6,047
  • 13
  • 49
  • 81