<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property >/WEB-INF/tiles-definitions.xml</strong>. So we have to create a file called tiles-definitions.xml in WEB-INF directory.
<img src="//www.viralpatel.net/app/uploads/2008/12/creating-tiles-definition.png" alt="" title="creating-tiles-definition" width="215" height="188" class="alignnone size-full wp-image-351" />
<h2>Creating Application</h2>
We will create a Header and a Footer that we will integrate with our sturts application. We will render this header and footer using Tiles.
Create two JSPs, Header.jsp and Footer.jsp and copy following content in it.
<strong>Header.jsp</strong>
<!-- wp:code {"language": "html"} --><pre class="wp-block-code"><code></code></pre><!-- /wp:code -->
<div style="width: 100%; height: 200px; background-color: #ABBAF3">
<h3>Tiles Plugin Example using Struts &amp;amp;amp; Eclipse</h3>
</div>
Code language: HTML, XML (xml)
Footer.jsp <div style="width: 100%; height: 50px; background-color: #ABBAF3">
Copyright &amp;amp;amp;copy viralpatel.net
</div>
Code language: HTML, XML (xml)
Also, create a Layout.jsp file in your WebContent folder and copy following code in it. <%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles"%>
<tiles:importAttribute />
<HTML>
<HEAD>
<TITLE><tiles:getAsString name="title" /></TITLE>
</HEAD>
<BODY>
<TABLE width="100%" height="100%" border="0">
<TR>
<TD valign="top" height="10px">
<tiles:insert name="header" attribute="header" />
</TD>
</TR>
<TR>
<TD valign="middle" align="center">
<tiles:insert name="body" attribute="body" />
</TD>
</TR>
<TR>
<TD height="10px">
<tiles:insert name="footer" attribute="footer" />
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Code language: HTML, XML (xml)
Layout.jsp file will define overall layout of web page. I have used a table based layout here. You can use a DIV based layout and align all the components using CSS. Note that we have used a tag <tile:insert>
in order to place the respective elements on this page. This will be more clear once you create tiles-definitions.xml file. Now copy following code in tiles-plugins.xml file. <?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.3//EN"
"http://struts.apache.org/dtds/tiles-config_1_3.dtd">
<tiles-definitions>
<definition name="layout" page="/Layout.jsp">
<put name="header" value="/Header.jsp" />
<put name="body" value="" />
<put name="footer" value="/Footer.jsp" />
</definition>
<definition name="/tiles.home" extends="layout">
<put name="title" value="Welcome: Tiles Plugin Sturts Tutorial" />
<put name="body" value="/wome.jsp" />
</definition>
</tiles-definitions>
Code language: HTML, XML (xml)
Here we have replace names like title, body, header, footer etc with the content of the JSPs. Hence tiles will replace the tag <tile:insert>
with appropriate content in Layout.jsp. Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
Good work... brother..its good for all begginer.. plz.. if possible give Hibernate tutorial in eclipse..plz.. plz..pz...
Thanks Rakesh for the comment..
I will sure try to put some step by step tutorials on Hibernate and other ORMs on this site.
you have not provided sufficient codes. Nobody can run the application using your codes.
Hi Richa, I have provided full code and with this you must be able to run the application. Let me know exactly where you are getting the problem.
Have you created basic struts application? I have kept source code in the tutorial: http://viralpatel.net/tutorial-creating-struts-application-in-eclipse/
0
Hi viral,
I am also getting the same exception .ie javax.servlet.ServletException: Error - tag importAttribute : no tiles context found.
Please guide me to resolve this.
HI! im getting this error cud u plz help me..........
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
org.apache.struts.tiles.xmlDefinition.FactorySet.getDefinition(FactorySet.java:116)
org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper.getDefinition(ComponentDefinitionsFactoryWrapper.java:87)
org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:184)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803
In fact for any info im visiting u r site, very good site..helping lot
I m getting this error PLEASE REPLY!!!!!!!!!!!!!!
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index3.jsp at line 3
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Can't get definitions factory from context.
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.jsp.JspException: Can't get definitions factory from context.
org.apache.struts.tiles.taglib.InsertTag.processDefinitionName(InsertTag.java:580)
org.apache.struts.tiles.taglib.InsertTag.createTagHandler(InsertTag.java:479)
org.apache.struts.tiles.taglib.InsertTag.doStartTag(InsertTag.java:441)
org.apache.jsp.index3_jsp._jspx_meth_tiles_005finsert_005f0(index3_jsp.java:86)
org.apache.jsp.index3_jsp._jspService(index3_jsp.java:59)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!
Please show how to use the definition tiles.home that is created