Struts 2.x Tiles Framework (Netbeans IDE) – Part 01

Struts 2.x Tiles Framework (Netbeans IDE) provide us an easy and effective way to manage our web page contents.

Struts 2.x Tiles Framework provide us to make effective and easily maintainable  websites using struts 2.x. With the use of tiles in developing web projects we are able to make and deliver changes in a particular area of page on user’s click for this we don’t need to write the whole page code on all the pages. Just what we need is to integrate our project with tiles framework.

Here is what we need to develop struts 2.x tiles based web project:

1. Create a web project : Visit this link to know “How to Start or Create a new Struts 2.x Web project?“.
2. After Successful creation of the web project. Now click on libraries option present on the left of Netbean IDE window under projects category.
3. In libraries right click on any struts 2.x libraries and in the appeared pop click remove. After doing this removal you will find that all the struts 2.x libraries will be removed.

Now, make sure you have downloaded the following jar files:

  1. commons-beanutils-1.7.0.jar
  2. commons-digester-2.0.jar
  3. commons-fileupload-1.2.2.jar
  4. commons-io-2.0.1.jar
  5. commons-lang-2.5.jar
  6. commons-logging-api-1.1.jar
  7. freemarker-2.3.16.jar
  8. javassist-3.11.0.GA.jar
  9. ognl-3.0.1.jar
  10. struts2-core-2.2.3.jar
  11. struts2-tiles-plugin-2.2.3.jar
  12. tiles-api-2.0.6.jar
  13. tiles-core-2.0.6.jar
  14. tiles-jsp-2.0.6.jar
  15. xwork-core-2.2.3.jar

Before moving ahead make sure you have downloaded all the above mentioned plugins as this plugins are required to build struts 2.x tiles based web applications.’

After you have downloaded these jar files, again right click on libraries and then select add jar files option. A new window pop ups, now locate your downloaded plugins and add all the jar files one by one or all at the same time.

Download all tiles plugins from here

Now click on your root directory and locate and open web.xml file under WEB-INF folder. Add the following code block inside …. You can add it in center-mid after the end of previous code tag and before the start of the new.
1. web.xml configuration:

org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG

/WEB-INF/tiles.xml

org.apache.struts2.tiles.StrutsTilesListener

  2. Now in the same directory where the web.xml file is present create a tiles.xml file by right clicking on WEB-INF folder -> New -> Other -> locate xml folder and select xml document from right name the document as tiles.xml and click on finish.
Add the following code after opening the tiles.xml file:
Save all files!!! Now you are ready to develop struts 2.x tiles programs.
For further information and example visit  Struts 2.x Tiles Framework (Netbeans IDE)- Part(2).