0

I have a Spring + Apache Tiles 3 Aplication.

I have a layout and inside of this, the header, the body and the footer:

defaultLayout.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title><tiles:getAsString name="title" /></title>
    <link href="<c:url value='/static/css/bootstrap.css' />"  rel="stylesheet"></link>
    <link href="<c:url value='/static/css/app.css' />" rel="stylesheet"></link>
</head>

<body>
        <header id="header">
            Web Application Context Path="${pageContext.request.contextPath}"
            <tiles:insertAttribute name="header" />
        </header>

        <section id="sidemenu">
            <tiles:insertAttribute name="menu" />
        </section>

        <section id="site-content">
            <tiles:insertAttribute name="body" />
        </section>

        <footer id="footer">
            <tiles:insertAttribute name="footer" />
        </footer>
</body>
</html>

The "${pageContext.request.contextPath}" works fine inside the Layout, but not on the JSP children's:

menu.jsp

<nav>
<a href="${pageContext.request.contextPath}/"><img class="logo" src="${pageContext.request.contextPath}/static/img/Linux-icon.png"></a>
<ul id="menu">
    <li><a href="${pageContext.request.contextPath}/">Home</a></li>
   <li><a href="${pageContext.request.contextPath}/products">Products</a></li>
   <li><a href="${pageContext.request.contextPath}/contactus">Contact Us</a></li>
</ul>

This prints the "${pageContext.request.contextPath}" "as is" in the result HTML.

Ildelian
  • 1,278
  • 5
  • 15
  • 38

2 Answers2

1

Try to use <%@ page isELIgnored="false" %>. It will solve your problem

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
kavtel
  • 11
  • 2
0

Since you mentioned HTML code and say that the context path is printed "as-is", is this code in HTML file? Then it will not work.

Check this question - ${pageContext.request.contextPath} is not working on plain HTML

Community
  • 1
  • 1
Shankar
  • 2,625
  • 3
  • 25
  • 49