aspose file tools*
The moose likes Struts and the fly likes Enabling/Installing Struts Tiles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Enabling/Installing Struts Tiles" Watch "Enabling/Installing Struts Tiles" New topic
Author

Enabling/Installing Struts Tiles

Jared Cheung
Greenhorn

Joined: Mar 21, 2012
Posts: 4
Hi all,

So, I have been researching struts-tiles for an existing java/jsp web application I am currently working on. I have found several sources on how to install/enable struts-tiles and they are all a little different. Here's what I have done so far:

In struts-config.xml I added these line:

<action path="/myTilesAction" foward="my.tiles.action" />

and

<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-def.xml" />
</plug-in>


In web.xml I added these lines:

<init-param>
<param-name>chainConfig</param-name>
<param-value>org/apache/struts/tiles/chain-config.xml</param-value>
</init-param>


and

In tiles-def.xml I have these lines:

<definition name="my.tiles.action" path="/jsp/myTilesPage.jsp">
<put name="Header" value="/jsp/myTileHeader.jsp">
<put name="Footer" value="/jsp/myTile/Footer.jsp">
</definition>


Apparently in the version I downloaded from apache.org the .zip file has a struts-tiles-1.3.10.jar file which I placed in the /WEB-INF/lib folder of our application. Hopefully I am so far so good. What I am having trouble with is how to reference the struts-tiles tab library on my JSP pages. I've seen two ways to do this:

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %> OR <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>

My dilema is I am not sure how the server on which our application runs would react to a uri reference to an outside server and there is no file under /WEB-INF called struts-tiles.tld. In the /WEB-INF folder we do have .tld files for struts - bean,html,logic,nested. Where do I find the file struts-tiles.tld. As mentioned the .zip file only had a struts-tiles-1.3.10.jar file but didn't contain a struts-tiles.tld.

Any help to resolve this would be greatly appreciated.
Jared Cheung
Greenhorn

Joined: Mar 21, 2012
Posts: 4
In addition to this, I just attempted to start my application and received an HTTP 404 Servlet action not available ERROR. Once I removed the <plug-in></plug-in> entry from the struts-config.xml the application worked fine. I am pretty new to apache struts only having worked with it here and there for the past month and a half. Very confused at the moment.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Jared,
Welcome to Ranch!

When I have done this long back, I got the tld from the jar I downloaded. I still have the download and the location of it as I see is struts-1.3.10-all\struts-1.3.10\lib\struts-tiles-1.3.10.jar\META-INF\tld\struts-tiles.tld. I dropped this in the WEB-INF and had the URI to point the same location and it worked like charm.
Later if you still have troubles with this, post the exception stack trace from your server log (something like 'HTTP 404 Servlet action not available' doesn't lead us in any direction). Also look into this post for the steps I followed.


Have Fun with Java
little,little.. little by little makes a lot..
Jared Cheung
Greenhorn

Joined: Mar 21, 2012
Posts: 4
Hi Shankar,

thanks for posting a response. The day followig this post I figured out what I did was downloaded the wrong zip file. Instead of the Full Distribution I downloaded just the jar files. Your response is exactly what I did finally and it worked. I forgot to return and post a response since we did an update and all heck broke lose :-D.
 
jQuery in Action, 2nd edition
 
subject: Enabling/Installing Struts Tiles