• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP - Tag Files used recursivily throws exception !

 
Rahul Ravikumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have developed a simple tag file, which given a directory lists all the sub-directories and files in a list (recursive.tag). For this, i made a recursive call to the tag file as shown below:

<%@tag body-content="empty" %>
<%@attribute name="rootNode" type="java.io.File" required="true" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<c:set var="node" value="${rootNode}"></c:set>

<%
java.io.File rootDir = (java.io.File) jspContext.getAttribute("node");
java.io.File [] items = rootDir.listFiles();
jspContext.setAttribute("items",items);
%>

<c:forEach var="item" items="${items}">

<c:choose>
<c:when test="${item.file}">
  • ${item.absolutePath}

  • </c:when>
    <c: otherwise>
    <tags:recursive rootNode="${item}"/> <-- Recursive Call <--
    </c: otherwise>
    </c:choose>

    </c:forEach>

    My JSP file is :

    <%@page import="java.io.File" %>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
    <%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>

    <html>
    <body>
    <%
    File node = new File("C:\\Work");
    request.setAttribute("node", node);
    %>
    <tags:recursive rootNode="${node}"/>
    </body>
    </html>

    When i deploy this application in Tomcat it works. However in Weblogic 10.3, I get the following error:

    recursive.tag:22:5: The tag handler class was not found "jsp_servlet._tags.__recursive_tag".
    <tags:recursive rootNode="${item}"/>
    ------------
    recursive.tag:22:5: The tag handler class was not found "jsp_servlet._tags.__recursive_tag".
    <tags:recursive rootNode="${item}"/>
    ------------
    index.jsp:12:4: The tag handler class was not found "jsp_servlet._tags.__recursive_tag".
    <tags:recursive rootNode="${node}"/>
    ------------
    index.jsp:12:4: The tag handler class was not found "jsp_servlet._tags.__recursive_tag".
    <tags:recursive rootNode="${node}"/>
    ------------
    index.jsp:12:19: This attribute is not recognized.
    <tags:recursive rootNode="${node}"/>
    ------

    I then recompiled the tag file by removing the recursive call in the tag file and refreshing the JSP. After this, i added the recursive call back and recompiled the tag file again and lo-behold the page works the way it is supposed to i.e. it lists all the directories and files under a given directory.

    Anyone else facing similar problems with Weblogic 10.3, when placing recursive calls in tag files? Any suggestions would be appreciated.
     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It's been a few weeks since you made the post and you haven't received any replies yet... I'm wondering if you've found a solution? I seem to be running into a similar problem where WebLogic 10.3 does not want to compile a tag file with recursive calls in it.
     
    Rahul Ravikumar
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No, there is no way of making recursive calls to tag files work. However, there is a work around :

    This was my old tag file :

    <%@tag body-content="empty" %>
    <%@attribute name="rootNode" type="java.io.File" required="true" %>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
    <%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>

    <c:set var="node" value="${rootNode}"></c:set>

    <%
    java.io.File rootDir = (java.io.File) jspContext.getAttribute("node");
    java.io.File [] items = rootDir.listFiles();
    jspContext.setAttribute("items",items);
    %>

    <c:forEach var="item" items="${items}">

    <c:choose>
    <c:when test="${item.file}">
    # ${item.absolutePath}

    </c:when>
    <c: otherwise>
    <tags:recursive rootNode="${item}"/> <-- Recursive Call <--
    </c: otherwise>
    </c:choose>

    </c:forEach>

    I changed the tag file into a jsp page called 'tags.jsp' as shown below.

    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

    <%--rootNode : java.io.File --%>

    if(request.getAttribute("rootNode") == null){
    return;
    }

    <c:set var="node" value="${rootNode}"></c:set>

    <%
    java.io.File rootDir = (java.io.File) jspContext.getAttribute("node");
    java.io.File [] items = rootDir.listFiles();
    jspContext.setAttribute("items",items);
    %>

    <c:forEach var="item" items="${items}">

    <c:choose>
    <c:when test="${item.file}">
    # ${item.absolutePath}

    </c:when>
    <c: otherwise>

    <%--<tags:recursive rootNode="${item}"/> <-- Recursive Call <-- --%>
    <%
    request.setAttribute("rootNode", pageContext.getAttribute(item));
    pageContext.include("tags.jsp"); //<-- This now becomes a recursive call.
    %>


    </c: otherwise>
    </c:choose>

    </c:forEach>

     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    How did you find out that a tag file cannot be called recursively in WebLogic 10.3? Were you able to confirm this from Oracle/BEA tech support? Or did you just find that you couldn't get it to work, so reverted to the JSP include workaround?

    I'm curious because I've found that my recursive tag works in WebLogic 9.2 MP1 and Jetty 6.1.7. You've noted already that yours works in Tomcat. Why wouldn't it work in WebLogic 10.3? I don't see anything in the JSP 2.1 spec that states it isn't allowed. I do find a statement that says JSP fragments (a type of attribute on a tag) can be called recursively, which would make me think tag files should be able to be called recursively, but I could be wrong.
     
    Rahul Ravikumar
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Recursive tags were working for me in 9.2 MP1 as well. I posted this question in the Oracle/BEA forums and did not get any replies whatsoever. I even filed a bug. Yes, the JSP Spec allows for recursive calls, but try conveying that message to Oracle/BEA.
     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you for the quick response! I'm still trying to work with Oracle support on it, but from the sounds of it I may not get too far.
     
    Marcus Kraßmann
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    just to be complete:
    I have the same issue when changing from WebLogic 10.2 to 10.3, so it really seems to be a 10.3 problem.

    I'll give the above workaround a try. Thanks for putting it online

    Kind regards
    Marcus
     
    Marcus Kraßmann
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Problem fixed! Instead of using recursive tags, I used a templating feature of my web framework that supports recursion, too.
    Thanks again for the hint
     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Marcus Kraßmann wrote:Problem fixed! Instead of using recursive tags, I used a templating feature of my web framework that supports recursion, too.
    Thanks again for the hint

    Which web framework are you using? Could you give an example?
     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    For those who are watching this thread...

    Oracle has fixed the JSP tag file recursion issue. Right now it is only available as a private patch under a service request I filed with them; however, from what I've been told and from what I've seen in the bug reports, the fixes are supposed to be included in WebLogic 11.
     
    Deepak Bala
    Bartender
    Posts: 6663
    5
    Firefox Browser Linux MyEclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tim Stavenger wrote:For those who are watching this thread...

    Oracle has fixed the JSP tag file recursion issue. Right now it is only available as a private patch under a service request I filed with them; however, from what I've been told and from what I've seen in the bug reports, the fixes are supposed to be included in WebLogic 11.


    Thanks for the info. Do you have a link to the service ticket or any publicly available information where the ticket can be watched ?
     
    Tim Stavenger
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Deepak Bala wrote:Thanks for the info. Do you have a link to the service ticket or any publicly available information where the ticket can be watched ?


    All of the links I have available to me are requesting a My Oracle Support login, so unfortunately I don't believe Oracle has its support site setup such that you can see other people's support tickets.
     
    Deepak Bala
    Bartender
    Posts: 6663
    5
    Firefox Browser Linux MyEclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tim Stavenger wrote:
    Deepak Bala wrote:Thanks for the info. Do you have a link to the service ticket or any publicly available information where the ticket can be watched ?


    All of the links I have available to me are requesting a My Oracle Support login, so unfortunately I don't believe Oracle has its support site setup such that you can see other people's support tickets.


    Thats all right. Thanks again
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic