Struts and Tiles - Steps to use Struts and Tiles

By: Grenfel Emailed: 1700 times Printed: 2203 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

  1. Add TilesRequestProcessor to struts-config.xml
    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
  2. Define the Tiles Plugin
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
    <set-property property="moduleAware" value="true"/>
    </plug-in>
  3. Create an empty Tiles definition file tiles-defs.xml under /WEB-INF directory
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE
    tiles-definitions PUBLIC
    "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
    <tiles-definitions>
    </tiles-definitions>
    d) Add the base definition to the tile definition xml

    <definition name="base.definition" path="/Layout.jsp">
    <put name="title" value=""/>
    <put name="header" value="/common/header.jsp" />
    <put name="footer" value="/common/footer.jsp" />
    <put name="body" value="" />
    </definition>
  4. Create the definition for each of the three pages by extending the above definition and overriding the empty values
    <definition name="search.page" extends="base.definition">
    <put name="title" value="Customer Search and List"/>
    <put name="body" value="/CustomerSearchList.jsp" />
    </definition>
    <definition name="customer.page" extends="base.definition">
    <put name="title" value="XYZ Co. Please enter your details"/>
    <put name="body" value="/CustomerForm.jsp" />
    </definition>
    <definition name="dberror.page" extends="base.definition">
    <put name="title" value="An error occured"/>
    <put name="body" value="/DatabaseError.jsp" />
    </definition>
  5. Change the references to physical jsps in struts-config.xml and replace them with one of the above names. For instance, change all references to “/CustomerForm.jsp” as “customer.page” [No “/” is required with Tiles.]

Struts Home | All Struts Tutorials | Latest Struts Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(2)


1. View Comment

steps 2 create and use tiles

View Tutorial          By: sasank at 2008-10-03 08:06:43
2. View Comment

i have been trained in java stream. But i dont know anything in java. a girl is needed to teach me. Contact me on 9812345670

View Tutorial          By: savio at 2013-01-23 10:15:51

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Grenfel
Verifying a Signed JAR File example
Bitwise and Bit Shift Operators example in Java
JavaBeans Basic Concepts
The Differences Between Simple and Classic Tags in JSP
Bitwise Logical Operators in C
DispatchAction in Struts
union example program in C
Comparison operators in JSP
Basics of Structures in C
register Variables in C
Struts and Tiles - Steps to use Struts and Tiles
The if else statement in C
Character Counting sample program in C
Installing JSF
cin.ignore() in C++

More Tutorials in Struts
Configuring JDBC DataSources in Struts
Struts Classes
FAQ: Why was reload removed from Struts (since 1.1)?
FAQ: Why are my checkboxes not being set from ON to OFF?
Using JavaScript to submit a form in Struts
How to prepopulate a form in Struts
Simple example of using the requiredif Validator rule in Struts
Chaining actions in Struts
When is the best time to validate input in Struts
What is a Plug-in and how to use Java plug-ins with Struts?
7 Best Practices of Struts
Origin and Architecture of Struts
ActionErrors and ActionError in Struts
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
Handling multiple buttons in HTML Form in Struts

More Latest News
Most Viewed Articles (in Struts )
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
What is Struts? Which Version of Struts to use?
Handling multiple buttons in HTML Form in Struts
Using JavaScript to submit a form in Struts
ActionErrors and ActionError in Struts
Model 1 Architecture
MVC Architecture (Model 2 Architecture)
FAQ: Why are my checkboxes not being set from ON to OFF?
Editing struts-config.xml in a Struts Application
Introduction to Struts Architecture
Struts and Tiles - Steps to use Struts and Tiles
ForwardAction in Struts
Handling Duplicate Form Submissions in Struts
What is a Model View Controller (MVC) Model?
Configuring JDBC DataSources in Struts
Most Emailed Articles (in Struts)
What is a Model View Controller (MVC) Model?
Struts and Tiles - Steps to use Struts and Tiles
Creating Struts Modules
ActionErrors and ActionError in Struts
History of Struts
WebWork 2 is now Apache Struts 2
Creating the first application using Struts 2
IncludeAction in Struts
Handling Duplicate Form Submissions in Struts
Guidelines for Struts Application Development
7 Best Practices of Struts
How to prepopulate a form in Struts
Is Struts the most popular web application framework for Java?
Configuring JDBC DataSources in Struts
Downloading and installing Struts