I want to check if the `name` already exists on the database. So I will do a Post. Let's assume the name already exists. 

How do I throw an error so it shows an error in the html, using the error: function of the ajax?

```
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String name = request.getParameter("name");

    //Check if name exists and return true or false
    if(exists)
        throw error to ajax
    }
    //else save data
}

//Ajax Post
$('#btnSubmit').click( function() {
    $.ajax({
        type: 'post',
        url: 'GeneralSetup',
        data: data,
        success: function () {
            window.location.href = "/clients.jsp";
        },
        error: function () {

        }
    });
    return false;
});

```