Probably have to trap these exceptions in your
servlet's and send a response back that tells the ajax call it's an exception. I imagine you could be as generic or a specific as you'd like with your exception-response.
Otherwise, ajax calls don't have a way to differentiate between successful responses and erroneous responses.
IMO jQuery has a good ajax api. Works well for this scenario.