I am using Ajax in a jsp page wherein we have a form of filling with Username and Password. I am able to retrieve them in the same page. But while passing it to a Servlet i.e. Admin.java file both username and password are not been passed.
Code:
function prepareLoginDialog(){
        $dialog = $('<div></div>')
        .html('<div id="dialog-confirm" title="Enter the login details here :">'+
            'User: <input type="text" id="u" name="u" ></input><br />'+
            'Pass: <input type="password" id="p" name="p" ></input>'+
            '</div>')
            //System.out.println(user);
        //System.out.println(pass);
        .dialog({
            autoOpen: false,
            modal: true,
            title: 'Login',
            buttons: {
                'Login': function() {
                    //Send Login Request to Server
                    var user = document.getElementById("u").value;
                    var pass = document.getElementById("p").value;
                    alert(user);
                    alert(pass);
                    //System.out.println(u.text);
                    login(user,pass);
                    $(this).dialog('close');
                },
                Cancel: function() {
                    $(this).dialog('close');
                }
            }
The Login Function is:
function login(user, pass) {
        //ToDo: User Login check
        alert(user);
        $.ajax({
            type:"GET",
            url: "Admin?action=login",
            dataType: "html",
            data: { username: user, password: pass },
            success: function(response){
                prepareLogoutDialog();
                prepareLoggedIn();
            }
        });
In the Java file it is
request.getSession().setAttribute("access", true);
            System.out.println("Admin:doGet:login:true");
            System.out.println("u");
            String userName = request.getParameter("u");
            String password = request.getParameter("p");
            System.out.println(userName);
            System.out.println(password);
Not getting printed. Do I need to convert the username and password to string before passing? If so how do we do that?
Please help.
 
     
     
    