Question

I want to increase morphism of my jsp includees, which I include into jsp pages using jsp:include tag. Problem is this tag only works with relative path, considering "/" as current path. This leads to need to refactor relative path each time when page with includes is moved to another folder.

To avoid it, i want to use webapp context relative path instead of jsp-relative path, like in this example:

**old main.jsp**
<jsp:include path="../../../components/table/table.jsp" />

 **new morphable main.jsp**
 <my:getRoot var="toRoot"/>
 <jsp:include path="${toRoot}/components/table/table.jsp" />

 **Web app file structure**
 /app/demo/tableview/main.jsp
 /components/table/table.jsp
 /WEB-INF

The question is how to get relative path of jsp so getRoot tag can use it to build 'get-to-root' relative path?

Also suggestion of other ways are welcome.

No correct solution

OTHER TIPS

I've found a solution:

<c:import context="/" url="/components/table/table.jsp" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top