This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Tiles Context is there and is not there?

Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone.
I have a really strange problem and I guess I went blind and simply can't see what is going on.
I'm using tiles (for the first time) and getting the 2 errors below.

First I've got this one:
Error - tag.getAsString : component context is not defined. Check tag syntax

then I added SCRIPTING FOR TESTING to see what is going on and this is what I get

***Title is: Categories
***header is: /jsp/Header.jsp
***Crumbs is: /jsp/Crumbs.jsp
***Category is: /jsp/Category.jsp

Now, as you can see below, these results come from the very Context "which is not defined" ???

then I removed <tiles:getAsString name="title"/> and inserted just 'MyTitle' (hardcoded title that is)
and got this error (the if part of SCRIPTING FOR TESTING):


Can not find Tile context for 'org.apache.jsp.CategoryLayout_jsp'. TilesAction subclasses must be called from a Tile
at org.apache.jsp.CategoryLayout_jsp._jspService(

and this in the page (the else part of SCRIPTING FOR TESTING):

***Title is: My app title - categories
***header is: /jsp/Header.jsp
***Crumbs is: /jsp/Crumbs.jsp
***Category is: /jsp/Category.jsp

also from the "unexisting" context.

Below the jsp and the tiles-def.xml

THE CategoryLayout.jsp:
<%@ page language="java" %>
<%@ taglib uri="" prefix="bean" %>
<%@ taglib uri="" prefix="html" %>
<%@ taglib uri="" prefix="logic" %>
<%@ taglib uri="" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:base />

<tiles:getAsString name="title"/> [later replaced by just 'MyTitle']




org.apache.struts.tiles.ComponentContext context = org.apache.struts.tiles.ComponentContext.getContext(request);

if (context == null) {

throw new ServletException("Can not find Tile context for '"

+ this.getClass().getName()

+ "'. TilesAction subclasses must be called from a Tile");

} else {

out.print("<br />");
out.print("***Title is: " + (String) context.getAttribute("title"));
out.print("<br />");
out.print("***header is: " + (String) context.getAttribute("header"));
out.print("<br />");
out.print("***Crumbs is: " + (String) context.getAttribute("crumbs"));
out.print("<br />");
out.print("***Category is: " + (String) context.getAttribute("body"));

<tiles:insert attribute="header" />

<TR vAlign=top>

<tiles:insert attribute="leftmenu" />
<tiles:insert attribute="crumbs" />
<tiles:insert attribute="body" />


<!-- Base Tiles Definition -->
<definition name="base.definition" path="/siteLayout.jsp">
<put name="title" value="My app title"/>
<put name="header" value="/jsp/Header.jsp" />
<put name="leftmenu" value="/jsp/LeftMenu.jsp" />
<!-- Tiles Definition of welcome page -->
<definition name="page.welcome" extends="base.definition">
<put name="body" value="/jsp/welcome.jsp" />
<!-- Tiles Definition of Categories -->

<definition name="page.categories" extends="base.definition" path="/CategoryLayout.jsp">
<put name="title" value="My app title - categories"/>
<put name="crumbs" value="/jsp/Crumbs.jsp" />
<put name="body" value="/jsp/Category.jsp" />

<definition name="navigation.definition" path="/jsp/Navigate.jsp" />



The page is displayed correctly and everything works just fine, except for this exception stack on the sysout.

Any ideas?

ps. if you look carefully in the SCRIPTING FOR TESTING part you'll see that there is an if-else construction, but they seem both to be executed???

Milan.javascript: x()
[ March 19, 2007: Message edited by: Milan Tomc ]
Milan Tomc
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my Action class (within method getMainCategories() ) :

I have got this

What am I missing here?

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic