Send values from jsp to Servlet

i have a jsp in which i have select tag and i want to get the and the value selected from the select in jsp in my Servlet

<select id="listoffood" name="dropdown" onchange="foodname();">
<option value="bg">Burger</option>
<option value="pas">pasta</option>
<option value="pi">pizza</option>
<div id='content'></div>

here is the javascript code

function foodname()

  var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }'GET', "InformationServlet", true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    self.xmlHttpReq.onreadystatechange= function ()
        if (self.xmlHttpReq.readyState==4)
        if (self.xmlHttpReq.status == 200)



What i have done is used a get Attribute like this but it aint working its showing null

protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException 

    // TODO Auto-generated method stub

    String coun = request.getParameter("dropdown");
    PrintWriter out=response.getWriter();
    System.out.println("here : "+coun);

Thanks in advance and any piece of code is highly appreciated.


Just change your AJAX open() request as

var select = document.getElementById("listoffood");'GET', "InformationServlet?dropdown=" + select.options[select.selectedIndex].value, true);

Need Your Help

Have a trouble with using $bindTo twice

javascript angularjs firebase ionic-framework angularfire

I'm new to AngularJs and now I'm trying to work with Firebase.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.