sending a selected value from a dropdownlist to a servlet with xhr
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-03-23T10:28:15Z
Indexed on
2010/03/23
11:33 UTC
Read the original article
Hit count: 366
I am trying to send the clicked value of a dropdown list to my servlet to run a SQL query using the value received. To do it I am using Ajax like that:
function showProject(prj) {
xmlhttp = GetXmlHttpObject();
if (xmlhttp == null) {
alert ("Browser does not support HTTP Request");
return;
}
var url = "ServletxmlGenerator.java";
idprj = prj.options[prj.selectedIndex].value;
url = url + "?idprj=" + idprj;
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
The servlet when
String projectcode=(String) request.getParameter("idprj");
returns null.
When I select a value from the JSP that construct the dropdown list and from which the function showProject
is handled the same thing is happned. It returns always null
. So the parameter(idprj)
is not passed anyway. How can I handle with this. I need to send the selected value to the servlet to run my SQL query.
© Stack Overflow or respective owner