I have a requirement to extend tcdl linking so that it resolves links without index.html. So for example, I want /home/news/index.html to be resolved to /home/news/ This is Website App in 2013 using Java. It is not DXA or DD4T.

What's the best way to do this? By overriding TagRenderer class?


2 Answers 2


So to answer my question, I have used approach as provided in Will's article:


So I extended TagRenderer class and provided implementation in doEndTag(). It works now.

public String doEndTag(Tag tag, StringBuffer stringBuffer, TransformContext transformContext, OutputDocument outputDocument)
            throws TCDLTransformerException {
        String type = tag.getAttribute("type", "");
        String tcm = tag.getAttribute("tcm", "");
        String attributes = tag.getAttribute("attributes", "");
        String parameters = tag.getAttribute("parameters", "");
        String anchor = tag.getAttribute("anchor", "");
        String text = tag.getAttribute("text", "");
        String urlonly = tag.getAttribute("urlOnly", "");
        String link = "";
        if (type.equalsIgnoreCase("page")) {
            link = generatePageLink(tcm, attributes, parameters, anchor, text, urlonly);
        } else if (type.equalsIgnoreCase("component")) {
            link = generateComponentLink(tcm, attributes, parameters, anchor, text, urlonly);

        if (StringUtils.isEmpty(link)){ 
            if(urlonly!=null && urlonly.length()==0) {
                link = "<!--" + tag.toString() + "-->";
            else if(urlonly!=null && urlonly.length()!=0){
        link = link.replaceAll("/index.html", "/");
        return  stringBuffer.toString();

Just to share my idea, In the past, I did implement using the following approach, the files to be served without extension using .NET ASPX website, you can do similar in java also I think.

  1. Using Rewrite rule to remove the extension
  2. Add the extension back to the server
  3. Navigation XML published with URLs extensionless
  4. For the ComponentLinks - created custom TBB to processed component link field and a rich text field to be resolved on CMS side with custom ComponentLink control without tcdl tag, Webapp side handled custom component link control to be configured to process the URL links with extensionless.

In your case, you can extend tcdl link on the content service side or web app side to process the links based on will blog.

Rewrite rule:

<rule name="RemoveASPX" enabled="true" stopProcessing="true">
  <match url="(.*)\.aspx" />
  <action type="Redirect" url="{R:1}" />
<rule name="AddASPX" enabled="true">
  <match url=".*" negate="false" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
  <action type="Rewrite" url="{R:0}.aspx" />

Rewrite rule for java refer to this StackExchange answer.

I hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.