Struts and Tiles - Steps to use Struts and Tiles

By: Grenfel Emailed: 1606 times Printed: 2077 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
Handling Duplicate Form Submissions in Struts
What is Struts? Which Version of Struts to use?
Model 1 Architecture
ForwardAction in Struts
Configuring JDBC DataSources in Struts
Editing web.xml in a Struts Application
Struts 1 vs Struts 2
MVC Architecture (Model 2 Architecture)
Struts and Tiles - Steps to use Struts and Tiles
Writing the first Struts application
ActionErrors and ActionError in Struts
What is a Plug-in and how to use Java plug-ins with Struts?
FAQ: Why are my checkboxes not being set from ON to OFF?
What is a Model View Controller (MVC) Model?
Most Emailed Articles (in Struts)
What is Struts? Which Version of Struts to use?
Use ImageButtonBean for Image based Form Submits in Struts
WebWork 2 is now Apache Struts 2
Using Checkbox & Radio Tags, html:select, html:options in Struts Forms
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
Simple example of using the requiredif Validator rule in Struts
Is Struts the most popular web application framework for Java?
What is a Model View Controller (MVC) Model?
Struts 1 vs Struts 2
Using Multibox in Struts
Using Multiple Message Resource Bundles in Struts
ForwardAction in Struts
IncludeAction in Struts
FAQ: Why was reload removed from Struts (since 1.1)?
Handling multiple buttons in HTML Form in Struts