title: how to return data to ajax from java Servlet
body: <p>i have my ajax function as follows:</p>
  
  <pre><code>$.ajax({
    type: 'GET',
    url: "/myservlet",
    data: {
    objects: '2',
    dimension: '2',
    },
    success: function( data ) {
    console.log(data);
    alert(data);
    },
    error:function(data,status,er) {
      alert("error: "+data+" status: "+status+" er:"+er);
     }
   });
  </code></pre>
  
  <p>and i have my servlet to process the data sent to /myservlet. I read from the ajax tutorial which said the data in the success function is the data that ajax got from the server side. But i don't know how to set this data or return this data from doGet method in a Java servlet to the frontend. It seems doGet is a void method and cannot return any values, isn't it? I am a freshman in web development, thanks in advance!</p>