I am communicating servlet to jQuery in following way.
jQuery:
$('.snd').click(function (){
    $.ajax({
        url: '/ProjectName/ServletName?action=test',
        data: {cl1: $('.t11').val()},
        success: function (response){
            $('.t12').val(response);
        }
    }); 
});
Servlet
if (action.compareTo("test") == 0) {
            action = "abc";
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.println("text1");
            } finally {
                out.close();
            }
        }
By doing this I am getting the result "text1"
Now what do I need to do if instead of sending normal text I want to send an object or an String array to the jQuery as response?
e.g
in servlet I have the following array
String[] ss= {"n1","n2"};
and in jQuery I want to use
$('.t12').val(response[0]);
to get result "n1"
 
     
    