Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:07:40+00:00 2026-06-01T17:07:40+00:00

I want Tiles to resolve ognl from the struts2 value stack. How to do

  • 0

I want Tiles to resolve ognl from the struts2 value stack. How to do this?

Using tiles 2.2.2 (although if a later version such as 3 could be used that is fine)

Here it mentions the new feature:
http://tiles.apache.org/2.2/framework/whats-new.html

Here it shows how to implement it: http://tiles.apache.org/2.2/framework/tutorial/advanced/el-support.html#OGNL_Support

But I’m not certain how to go about that in my project. Does anyone have tiles3 working in their struts2 project? I remember reading about some way to turn on all new features in tiles 3 by default but I can’t find a link to that page.

If configuration can be done in anyway with spring that is fine (if that helps, if not it is not an issue).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:07:42+00:00Added an answer on June 1, 2026 at 5:07 pm

    I love the tiles tempate system because it is simple and straight forward, with Tiles 2.2.2 you can have wild card support to push your struts2 conventions right into the template system and now there is OGNL too!

    Steps to add tiles 2.2.2 with OGNL support within tiles (Currently using Struts 2.3.1.2):

    1) Add the struts2-tiles-plugin

    2) Add the tiles 2.2.2 jars including the jars which add ognl support. Assumes maven: ALL group ids are: org.apache.tiles ALL versions are 2.2.2, the following are artifact ids :

    • tiles-api
    • tiles-core
    • tiles-extras
    • tiles-jsp
    • tiles-ognl
    • tiles-servlet

    Also needed to add the following:

    • log4j, log4j, 1.2.14 (Should already be part of the basic setup: http://struts.apache.org/2.x/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html)

    • slf4j-api, org.slf4j, 1.6.4

    • slf4j-simple, org.slf4j, 1.6.4

    By using the org.apache.tiles.extras.complete.CompleteAutoloadTilesListener you get Wild Cards, EL, OGNL, MVEL support in your tiles.xml

    Example web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <listener>
            <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
        </listener>
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    </web-app>
    

    struts.xml for a demo: The demo uses OGNL from struts to display a hard coded greeting message. Three action mappings exist “”, “test”, and “package/*” the value that follows the slash will be used by tiles to set a new title. A very trivial example but does show some useful features.

    <struts>
        <constant name="struts.devMode" value="true" />
        <constant name="struts.ui.theme" value="simple" />
        <constant name="struts.enable.SlashesInActionNames" value="true" />
        <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
        <package  name="basicstruts2"  namespace="" extends="tiles-default">
            <result-types>
                <result-type name="tiles" default="true" class="org.apache.struts2.views.tiles.TilesResult"/>
            </result-types>
            <action name="/**" class="com.kenmcwilliams.tiles.action.Test">
                <result>{1}</result>
            </action>
        </package>
    </struts>
    

    tiles.xml

    <?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="baseLayout" template="/WEB-INF/content/tiles/template.jsp">
            <put-attribute name="title" value="Default Title"/>
            <put-attribute name="header" value="/WEB-INF/content/tiles/header.jsp"/>
            <put-attribute name="body" value="/WEB-INF/content/tiles/body.jsp"/>
            <put-attribute name="footer" value="/WEB-INF/content/tiles/footer.jsp"/>
            <put-attribute name="variable"  expression="OGNL:greeting"/>
        </definition>
        <definition name="test" extends="baseLayout">
            <put-attribute name="title" value="Test Title"/>
        </definition>
        <definition name="WILDCARD:package/*" extends="baseLayout">
            <put-attribute name="title" value="{1}" type="string"/>
        </definition>
        <definition name="" extends="baseLayout">
        </definition>
    </tiles-definitions>
    

    /WEB-INF/content/tiles/body.jsp

    <div>
        This is the default body.
    </div>
    

    /WEB-INF/content/tiles/footer.jsp

    <div>
        This is the default footer.
    </div>
    

    /WEB-INF/content/tiles/header.jsp

    <div>
        This is the default header.
    </div>
    

    /WEB-INF/content/tiles/template.jsp

    <%@taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <%@page contentType="text/html" pageEncoding="UTF-8" %>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><tiles:insertAttribute name="title"/></title>
        </head>
        <body>
            <tiles:insertAttribute name="header"/>
            <tiles:insertAttribute name="body"/>
            <tiles:insertAttribute name="footer"/>
            <tiles:insertAttribute name="variable"/>
        </body>
    </html>
    

    Test.java Action

    package com.kenmcwilliams.tiles.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    import java.util.Map;
    import java.util.logging.Logger;
    import org.apache.struts2.interceptor.SessionAware;
    
    public class Test extends ActionSupport implements SessionAware{
        private static final Logger log = Logger.getLogger(Test.class.getName());
        @Override
        public String execute(){
            log.info("Test execute");
            return SUCCESS;
        }
    
        private String greeting = "Hello, World from Action!";
        public String getGreeting(){
            return greeting;
        }
    
        @Override
        public void setSession(Map<String, Object> session) {
            session.put("greeting", "Greetings from session!");
        }
    }
    

    That should now be enough to get tiles working for your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to resolve a status 405 that I get from the task queue
I want to use tiles in Struts2 framework. What is basic difference between tiles:insert
I want to have achieve something similar to Java Tiles framework using only client
In a Windows 8 Metro App I want the ListViewItems/Tiles to open a link
i need to do a series of url calls (fetching WMS tiles). i want
There are times when I want to test new code from the forums or
I want to use Spring-Tiles intergration. Here you can see how my app looks
I have tiles (png images) for an offline map and I want to create
I'm using .Net 2.0 and this is driving me crazy but there's probably some
I have an interface public interface IResolver<T> { T Resolve(); } I know this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.