apache tiles 2 JSPException including path
This question was asked a year ago, but if anyone runs into the same issue here is how I fixed it. If the definition tag's name parameter and add-attribute tag's value parameter are the same I think it throws a stackoverflow error message. When I change those names, it worked fine for me.
<definition name="Page" template="/share/layout.jsp"><put-attribute name="title" value="Page xyz" />
Admin
Updated on March 20, 2020Comments
-
Admin about 4 years
I create a java web application with using Hibernate framework. In WEB-INF, I created a new file: tiles-defs.xml, the below is the content in it:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" "http://tiles.apache.org/dtds/tiles-config_2_1.dtd"> <tiles-definitions> <definition name="Page" template="/share/layout.jsp"> <put-attribute name="title" value="Page" /> <put-attribute name="header" value="/share/header.jsp" /> </definition> <definition name="Index" extends="Page"> <put-attribute name="title" value="Vnmart" /> <put-attribute name="main" value="/home/IndexContent.jsp"/> </definition> </tiles-definitions>
And in web.xml, I added some rows:
<context-param> <param-name> org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG </param-name> <param-value> /WEB-INF/tiles-defs.xml </param-value> </context-param> <listener> <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class> </listener>
In web pages folder, I created home folder to contain 2 jsp files: Index.jsp and IndexContent.jsp. Index.jsp:
<%@taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> <tiles:insertDefinition name="Index"/>
And IndexContent.jsp:
<div>Home</div>
After that, I created a controller package, and add new Home servlet:
String view = "home/Index.jsp"; RequestDispatcher rd = request.getRequestDispatcher(view); rd.forward(request, response);
But when I ran, apache said: 'HTTP Status 404 - /Project2/' (Project2 is name of project). And then, I checked in Apache Tomcat Log, I found an error:
'SEVERE: Servlet.service() for servlet [Home] in context with path [/Project2] threw exception [org.apache.tiles.impl.CannotRenderException: JSPException including path '/layouts/layoutfront.jsp'.] with root cause javax.servlet.ServletException: File "/home/IndexContent.jsp" not found'
I have no ideas about this, I followed some tutorial how to working with tiles, but I'm still get stuck.
-
Santosh Joshi over 9 yearsThanks man, i was struggling with this problem and you saved my day. Is it a bug or something else.
-
Mustafa Mohammadi over 6 yearsThanks Dear for answer. It is awesome ^_^