首页 > 解决方案 > 向 JSP 传递/公开 VXML 应用程序根文档变量

问题描述

我需要在我的 VXML 应用程序根文档中定义的变量(其他文档修改)可用于 JSP/EL 页面。这里的想法是,基于这些变量的值,我可以向 JSP 添加逻辑以将不同的 VXML 块呈现回 IVR 浏览器。

到目前为止我所尝试的不会产生任何错误。它根本不会在 EL 中呈现预期的 VXML 代码块。我的猜测是我没有在 EL 中正确地取消引用它们。

以下是我尝试过的一些内容。

root.vxml 文档有

..
<var name="promptRetries" expr="''" />
...

开始.jsp:

<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" application="/root.vxml" >

……

<assign name="application.promptRetries" expr="'3'" />

......

<block>         
    <submit next="${pageContext.request.contextPath}/nextdoc.jsp" />
</block>

nextdoc.jsp

<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml" application="/root.xml" >

……

<!-- at this point I can print and see the value of 3 for promptRetries -->
<!-- How can I expose this to JSP to accomplish something like the code below 

I have used .equals() and other forms in the EL expression with no luck.

-->
<c:if  test="${(application.promptRetries eq 1)} ">
    <!--  Setting prompts for 1 retry -->                             
    <catch event="noinput undefined" count="1" >
        <audio expr="curPrompt2"/>
        <log  expr="buildLogStr(ibmCallId, documentName,frmName ,blkName,
            'event=noinput count=1 reprompt', '')" />        
    </catch>
</c:if>

…………

标签: javascriptjspvxml

解决方案


在 JSP 中开发 VoiceXML 应用程序时,需要注意有两个执行空间。首先,生成 VoiceXML 的 Java 服务器。其次,执行它的 VoiceXML 浏览器。

您已经有了一个使用 ${variable_name} 语法将数据从 JSP 传递到 VoiceXML 的示例。要将数据从 VoiceXML 传递到 JSP,您需要在提交元素中显式列出要发送的变量:

<submit next="${pageContext.request.contextPath}/nextdoc.jsp" namelist="promptRetries"/>

然后在您的第二个 JSP 页面中,使用

request.getParameter("promptRetries") 

访问从浏览器发送的变量。


推荐阅读