包含 JSP 文件的函数在 Lucee 而非 ACF 中返回空结果

Function that includes JSP file is returning an empty result in Lucee but not ACF

我有一个函数利用 JSP 文件的 include 来检索线程信息,然后将其转换为查询对象。函数 returns 一个空查询 Lucee,但它在 ColdFusion 中正确执行。

CFML:

<cffunction name="mainThreads" output="false" returntype="query" access="public">
        <cfargument name="filterPages" type="boolean" required="true">

        <cfscript>
        var threadStackDump = "";
        var thread = 0;
        var stackTrace = "";
        request.threads = arraynew(1);
        GetPageContext().include("putParentThreadInRequestScope.jsp");

        ThreadQuery = QueryNew("id, name, group, stacktrace, alive", "Integer, VarChar, VarChar, VarChar, Bit");
        QueryAddRow(ThreadQuery, arrayLen(request.threads));

        for ( thread = 1; thread lte arrayLen(request.threads); thread = thread + 1 )
        {
            QuerySetCell(ThreadQuery, "id", request.threads[thread].getId(), thread);
            QuerySetCell(ThreadQuery, "name", request.threads[thread].getName(), thread);
            QuerySetCell(ThreadQuery, "group", request.threads[thread].getThreadGroup().getName(), thread);
            QuerySetCell(ThreadQuery, "alive", request.threads[thread].isAlive(), thread);

            threadStackDump = "";
            stackTrace = request.threads[thread].getStackTrace();
            for ( element = 1; element lte arrayLen(stackTrace); element = element + 1 )
                if ( arguments.filterPages )
                {
                    if ( findNoCase('runPage',stackTrace[element]) neq 0 or findNoCase('runFunction',stackTrace[element]) neq 0 )
                        threadStackDump = threadStackDump & stackTrace[element] & "#chr(13)#";
                }
                else
                    threadStackDump = threadStackDump & stackTrace[element] & "#chr(13)#";

            QuerySetCell(ThreadQuery, "stacktrace", threadStackDump, thread);
        }
        return ThreadQuery;
        </cfscript>
    </cffunction>

JSP

<%          
    ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
    Thread threadList[]=new Thread[Thread.activeCount()];   

    threadGroup.enumerate(threadList);
    request.setAttribute("threads", threadList);
%>

代码在 Lucee 中不工作,但我不确定为什么。它与 java 版本有关吗?

我猜你忘记了 enable handling of .jsp in your web.xml,但是......你没有意识到它,因为问题代码在抑制所有输出的 cffunction 中执行!

从疑难解答 101 中吸取教训,分小块测试问题代码。首先分别执行 JSP include。如果它在屏幕上显示 JSP 代码,而不是执行它,那么您知道 JSP 处理未启用,这就是您的问题。

<cfscript>
   GetPageContext().include("putParentThreadInRequestScope.jsp");
   writeDump( request );
</cfscript>