开发者

Custom JSP tag error: did not find a Child Translator for "taglib"

So I am trying to work on a sample of creating a Custom tag to display current date. I did everything stated in the example, but on starting my server its throwing an error: did not find a Child Translator for "taglib". What needs to be fixed here?

Caused by: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ArchiveWrappedException
    at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ModuleRefImpl.getDeploymentDescriptor(ModuleRefImpl.java:167)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.open(DeployedModuleImpl.java:237)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.initialize(DeployedModuleImpl.java:436)
    ... 53 more
Caused by: org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
    at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getDeploymentDescriptor(WARFileImpl.java:147)
    at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getStandardDeploymentDescriptor(WARFileImpl.java:301)
    at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFileImpl.getDeploymentDescriptor(EARFileImpl.java:401)
    at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.ModuleRefImpl.getDeploymentDescriptor(ModuleRefImpl.java:165)
    ... 55 more
Caused by: java.lang.IllegalStateException: Parent Translator (WebAppTranslator(web-app,1971221886)) did not find a Child Translator for "taglib".

web.xml declaration is:

<taglib>
 <taglib-uri>myTags</taglib-uri>
 <taglib-location>/WEB-INF/lib/DateTagLib.tld</taglib-location>
</taglib>

TLD file:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<taglib>
   <tlibversion>1.0</tlibversion>
   <info>Custom Date Tag</info>

  <tag>
    <name>displayDate</name>
    <tagclass>com.demo.DateTag</tagclass>
    <bodycontent>empty</bodycontent>
    <info>Display Date</info>
  </tag>    

Tag Class:

package com.demo;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;

import java.io.IOException;
import java.text.*;
import java.util.*;

public class DateTag extends TagSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public int doStartTag() throws javax.servlet.jsp.JspException {
        HttpServletRequest req;
        Locale locale;
        HttpJspPage g;
        DateFormat df;
        String date;
        JspWriter out;

        req = (HttpServletRequest) pageContext.getRequest();
        locale = req.getLocale();
        df = SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL, locale);
        date = df.format(new java.util.Date());  

        try {
            out = pageContext.getOut();
            out.print(date);
            } catch(IOException ioe){
                throw new JspException("IO Error: " + ioe.getMes开发者_C百科sage());
            } //end try/catch

            return Tag.SKIP_BODY;

    } //end doStarttag

} //end DateTag

</taglib>


Well I figured it out. Instead of doing a "static reference" to your custom tag in Deployment Descriptor, I tried referencing it dynamically from the JSP page itself and it worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜