I'm encountering an issue with calling a servlet and I could use some assistance.
Here is a snippet from my web.xml file:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/test/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ajaxServlet</servlet-name>
<servlet-class>org.finki.exercise.servlet.AjaxServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ajaxServlet</servlet-name>
<url-pattern>/ajaxServlet/*</url-pattern>
</servlet-mapping></servlet>
I have a jsp page for testing purposes, where I am attempting to trigger the servlet through ajax
<a href="#" onclick="loadXMLDoc('eva')">proba</a>
Ajax function
function loadXMLDoc(value1)
{
var xmlhttp;
var url="ajaxServlet";
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("mid_title").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", url+"?url="+value1, true);
xmlhttp.send();
}
The loadXMLDoc function triggers the dispatcher servlet
http://localhost:8097/mavenproject1/test/ajaxServlet
. How can I trigger the ajaxServlet -
http://localhost:8097/ajaxServlet
?