I'm trying to make an ajax call from the tml page. The idea would be to invoke a servlet to return me a string. The javascript function is:

function getComment(paramId) {

            var xmlhttp;
            if (window.XMLHttpRequest)
                 {// code for IE7+, Firefox, Chrome, Opera, Safari
                 xmlhttp=new XMLHttpRequest();
                }
            else
            {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.onreadystatechange=function()
                {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
                    alert('El server responde' + xmlhttp.responseText);
                }
            }
            xmlhttp.open("GET","/myapp/combo/?personId=paramId",true);
            xmlhttp.send();

        } 

The url "/myapp/combo/" is mapped in web.xml:

    <servlet>
    <servlet-name>ComboServlet</servlet-name>
    <servlet-class>xxx.xxx.ComboServlet</servlet-class>
</servlet>


<servlet-mapping>
    <servlet-name>ComboServlet</servlet-name>
    <url-pattern>/combo/*</url-pattern>
</servlet-mapping>

The problem is that it seems that the url is wrong, because the servlet does not intercept the "GET". Does anyone know what I'm doing wrong, or if there is another way?

Thanks!!!

有帮助吗?

解决方案

What's happening is that tapestry is handling your ajax request and that's why your your servlet "does not intercept the GET".

you need to do the following in your tapestry's application module (the main tapestry service of your webapp)

public static void contributeIgnoredPathsFilter(Configuration<String> configuration)
{
    configuration.add("/combo/.*");
}

That should help.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top